@@ -47,7 +47,7 @@ |
||
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * @param \Exception|string $error |
|
| 50 | + * @param \Exception $error |
|
| 51 | 51 | */ |
| 52 | 52 | private function onError($error) |
| 53 | 53 | {
|
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | namespace Nekland\Woketo\Client; |
| 13 | 13 | |
| 14 | 14 | |
| 15 | -use Nekland\Woketo\Core\AbstractConnection; |
|
| 16 | -use Nekland\Woketo\Rfc6455\Handshake\ClientHandShake; |
|
| 17 | -use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
| 18 | -use React\Promise\PromiseInterface; |
|
| 15 | +use Nekland\Woketo\Core\AbstractConnection; |
|
| 16 | +use Nekland\Woketo\Rfc6455\Handshake\ClientHandShake; |
|
| 17 | +use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
| 18 | +use React\Promise\PromiseInterface; |
|
| 19 | 19 | use React\Stream\Stream; |
| 20 | 20 | |
| 21 | 21 | class Connection extends AbstractConnection |
@@ -28,17 +28,17 @@ |
||
| 28 | 28 | public function __construct(PromiseInterface $clientPromise, MessageProcessor $messageProcessor) |
| 29 | 29 | {
|
| 30 | 30 | parent::__construct($messageProcessor, new ClientHandShake()); |
| 31 | - $clientPromise->then(function (Stream $stream) {
|
|
| 31 | + $clientPromise->then(function(Stream $stream) {
|
|
| 32 | 32 | $this->stream = $stream; |
| 33 | 33 | $this->onConnection($stream); |
| 34 | - }, function (\Exception $error){
|
|
| 34 | + }, function(\Exception $error) {
|
|
| 35 | 35 | $this->onError($error); |
| 36 | 36 | }); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | private function onConnection(Stream $stream) |
| 40 | 40 | {
|
| 41 | - $stream->on('message', function (string $data) {
|
|
| 41 | + $stream->on('message', function(string $data) {
|
|
| 42 | 42 | $this->onMessage($data); |
| 43 | 43 | }); |
| 44 | 44 | } |
@@ -11,11 +11,11 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace Nekland\Woketo\Core; |
| 13 | 13 | |
| 14 | -use Nekland\Woketo\Exception\WebsocketException; |
|
| 15 | -use Nekland\Woketo\Message\MessageHandlerInterface; |
|
| 16 | -use Nekland\Woketo\Rfc6455\Handshake\HandshakeInterface; |
|
| 17 | -use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
| 18 | -use Psr\Log\LoggerAwareTrait; |
|
| 14 | +use Nekland\Woketo\Exception\WebsocketException; |
|
| 15 | +use Nekland\Woketo\Message\MessageHandlerInterface; |
|
| 16 | +use Nekland\Woketo\Rfc6455\Handshake\HandshakeInterface; |
|
| 17 | +use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
| 18 | +use Psr\Log\LoggerAwareTrait; |
|
| 19 | 19 | use React\Socket\Connection; |
| 20 | 20 | |
| 21 | 21 | abstract class AbstractConnection |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | private function initListeners() |
| 71 | 71 | { |
| 72 | - $this->stream->on('data', function ($data) { |
|
| 72 | + $this->stream->on('data', function($data) { |
|
| 73 | 73 | $this->processData($data); |
| 74 | 74 | }); |
| 75 | - $this->stream->on('error', function ($data) { |
|
| 75 | + $this->stream->on('error', function($data) { |
|
| 76 | 76 | $this->error($data); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $this->currentMessage = $message; |
| 115 | 115 | if ($this->currentMessage->isComplete()) { |
| 116 | 116 | // Sending the message through the woketo API. |
| 117 | - switch($this->currentMessage->getOpcode()) { |
|
| 117 | + switch ($this->currentMessage->getOpcode()) { |
|
| 118 | 118 | case Frame::OP_TEXT: |
| 119 | 119 | $this->getHandler()->onMessage($this->currentMessage->getContent(), $this); |
| 120 | 120 | break; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | } else { |
| 128 | 128 | // We wait for more data so we start a timeout. |
| 129 | - $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () { |
|
| 129 | + $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() { |
|
| 130 | 130 | $this->logger->notice('Connection to ' . $this->getIp() . ' timed out.'); |
| 131 | 131 | $this->messageProcessor->timeout($this->stream); |
| 132 | 132 | }); |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | |
| 12 | 12 | namespace Nekland\Woketo\Rfc6455\Handshake; |
| 13 | 13 | |
| 14 | -use Nekland\Woketo\Exception\RuntimeException; |
|
| 15 | -use Nekland\Woketo\Http\Request; |
|
| 14 | +use Nekland\Woketo\Exception\RuntimeException; |
|
| 15 | +use Nekland\Woketo\Http\Request; |
|
| 16 | 16 | use Nekland\Woketo\Http\Response; |
| 17 | 17 | |
| 18 | 18 | class ClientHandshake implements HandshakeInterface |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | $key = ''; |
| 31 | 31 | for ($i = 0; $i < 16; $i++) {
|
| 32 | - $key .= chr(mt_rand(0,255)); |
|
| 32 | + $key .= chr(mt_rand(0, 255)); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $key = base64_encode($key); |