|
|
@@ -16,6 +16,7 @@ namespace Workerman\Protocols;
|
|
|
use Workerman\Worker;
|
|
|
use Workerman\Lib\Timer;
|
|
|
use Workerman\Connection\TcpConnection;
|
|
|
+use Workerman\Connection\ConnectionInterface;
|
|
|
|
|
|
/**
|
|
|
* Websocket protocol for client.
|
|
|
@@ -43,7 +44,7 @@ class Ws
|
|
|
* @param ConnectionInterface $connection
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function input($buffer, $connection)
|
|
|
+ public static function input($buffer, ConnectionInterface $connection)
|
|
|
{
|
|
|
if (empty($connection->handshakeStep)) {
|
|
|
Worker::safeEcho("recv data before handshake. Buffer:" . bin2hex($buffer) . "\n");
|
|
|
@@ -227,7 +228,7 @@ class Ws
|
|
|
* @param ConnectionInterface $connection
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function encode($payload, $connection)
|
|
|
+ public static function encode($payload, ConnectionInterface $connection)
|
|
|
{
|
|
|
if (empty($connection->websocketType)) {
|
|
|
$connection->websocketType = self::BINARY_TYPE_BLOB;
|
|
|
@@ -299,7 +300,7 @@ class Ws
|
|
|
* @param ConnectionInterface $connection
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function decode($bytes, $connection)
|
|
|
+ public static function decode($bytes, ConnectionInterface $connection)
|
|
|
{
|
|
|
$data_length = \ord($bytes[1]);
|
|
|
|
|
|
@@ -352,10 +353,10 @@ class Ws
|
|
|
/**
|
|
|
* Send websocket handshake.
|
|
|
*
|
|
|
- * @param \Workerman\Connection\TcpConnection $connection
|
|
|
+ * @param TcpConnection $connection
|
|
|
* @return void
|
|
|
*/
|
|
|
- public static function sendHandshake($connection)
|
|
|
+ public static function sendHandshake(TcpConnection $connection)
|
|
|
{
|
|
|
if (!empty($connection->handshakeStep)) {
|
|
|
return;
|
|
|
@@ -397,10 +398,10 @@ class Ws
|
|
|
* Websocket handshake.
|
|
|
*
|
|
|
* @param string $buffer
|
|
|
- * @param \Workerman\Connection\TcpConnection $connection
|
|
|
+ * @param TcpConnection $connection
|
|
|
* @return int
|
|
|
*/
|
|
|
- public static function dealHandshake($buffer, $connection)
|
|
|
+ public static function dealHandshake($buffer, TcpConnection $connection)
|
|
|
{
|
|
|
$pos = \strpos($buffer, "\r\n\r\n");
|
|
|
if ($pos) {
|