@@ -12,18 +12,18 @@ |
||
12 | 12 | namespace Nekland\Woketo\Client; |
13 | 13 | |
14 | 14 | |
15 | -use Nekland\Woketo\Core\AbstractConnection; |
|
16 | -use Nekland\Woketo\Exception\Http\IncompleteHttpMessageException; |
|
17 | -use Nekland\Woketo\Exception\RuntimeException; |
|
18 | -use Nekland\Woketo\Exception\WebsocketException; |
|
19 | -use Nekland\Woketo\Http\Response; |
|
20 | -use Nekland\Woketo\Http\Url; |
|
21 | -use Nekland\Woketo\Message\MessageHandlerInterface; |
|
22 | -use Nekland\Woketo\Rfc6455\Frame; |
|
23 | -use Nekland\Woketo\Rfc6455\Handshake\ClientHandshake; |
|
24 | -use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
25 | -use React\EventLoop\LoopInterface; |
|
26 | -use React\Promise\PromiseInterface; |
|
15 | +use Nekland\Woketo\Core\AbstractConnection; |
|
16 | +use Nekland\Woketo\Exception\Http\IncompleteHttpMessageException; |
|
17 | +use Nekland\Woketo\Exception\RuntimeException; |
|
18 | +use Nekland\Woketo\Exception\WebsocketException; |
|
19 | +use Nekland\Woketo\Http\Response; |
|
20 | +use Nekland\Woketo\Http\Url; |
|
21 | +use Nekland\Woketo\Message\MessageHandlerInterface; |
|
22 | +use Nekland\Woketo\Rfc6455\Frame; |
|
23 | +use Nekland\Woketo\Rfc6455\Handshake\ClientHandshake; |
|
24 | +use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
25 | +use React\EventLoop\LoopInterface; |
|
26 | +use React\Promise\PromiseInterface; |
|
27 | 27 | use React\Socket\ConnectionInterface; |
28 | 28 | |
29 | 29 | class Connection extends AbstractConnection |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | $this->buffer = ''; |
53 | 53 | $this->handler = $handler; |
54 | 54 | |
55 | - $clientPromise->then(function (ConnectionInterface $stream) { |
|
55 | + $clientPromise->then(function(ConnectionInterface $stream) { |
|
56 | 56 | $this->stream = $stream; |
57 | 57 | $this->onConnection($stream); |
58 | - }, function (\Exception $error) { |
|
58 | + }, function(\Exception $error) { |
|
59 | 59 | $this->onError($error); |
60 | 60 | }); |
61 | 61 | } |
62 | 62 | |
63 | 63 | private function onConnection(ConnectionInterface $stream) |
64 | 64 | { |
65 | - $stream->on('data', function (string $data) { |
|
65 | + $stream->on('data', function(string $data) { |
|
66 | 66 | $this->onMessage($data); |
67 | 67 | }); |
68 | 68 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | if ($this->currentMessage->isComplete()) { |
125 | 125 | // Sending the message through the woketo API. |
126 | - switch($this->currentMessage->getOpcode()) { |
|
126 | + switch ($this->currentMessage->getOpcode()) { |
|
127 | 127 | case Frame::OP_TEXT: |
128 | 128 | $this->getHandler()->onMessage($this->currentMessage->getContent(), $this); |
129 | 129 | break; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | } else { |
137 | 137 | // We wait for more data so we start a timeout. |
138 | - $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function () { |
|
138 | + $this->timeout = $this->loop->addTimer(Connection::DEFAULT_TIMEOUT, function() { |
|
139 | 139 | $this->getLogger()->notice('Connection to ' . $this->getIp() . ' timed out.'); |
140 | 140 | $this->messageProcessor->timeout($this->stream); |
141 | 141 | }); |
@@ -11,19 +11,19 @@ |
||
11 | 11 | |
12 | 12 | namespace Nekland\Woketo\Core; |
13 | 13 | |
14 | -use Nekland\Woketo\Exception\NoHandlerException; |
|
15 | -use Nekland\Woketo\Exception\WebsocketException; |
|
16 | -use Nekland\Woketo\Message\MessageHandlerInterface; |
|
17 | -use Nekland\Woketo\Rfc6455\Frame; |
|
18 | -use Nekland\Woketo\Rfc6455\Handshake\HandshakeInterface; |
|
19 | -use Nekland\Woketo\Rfc6455\Message; |
|
20 | -use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
21 | -use Nekland\Woketo\Utils\SimpleLogger; |
|
22 | -use Psr\Log\LoggerAwareTrait; |
|
23 | -use Psr\Log\LoggerInterface; |
|
24 | -use React\EventLoop\LoopInterface; |
|
25 | -use React\EventLoop\Timer\TimerInterface; |
|
26 | -use React\Socket\Connection; |
|
14 | +use Nekland\Woketo\Exception\NoHandlerException; |
|
15 | +use Nekland\Woketo\Exception\WebsocketException; |
|
16 | +use Nekland\Woketo\Message\MessageHandlerInterface; |
|
17 | +use Nekland\Woketo\Rfc6455\Frame; |
|
18 | +use Nekland\Woketo\Rfc6455\Handshake\HandshakeInterface; |
|
19 | +use Nekland\Woketo\Rfc6455\Message; |
|
20 | +use Nekland\Woketo\Rfc6455\MessageProcessor; |
|
21 | +use Nekland\Woketo\Utils\SimpleLogger; |
|
22 | +use Psr\Log\LoggerAwareTrait; |
|
23 | +use Psr\Log\LoggerInterface; |
|
24 | +use React\EventLoop\LoopInterface; |
|
25 | +use React\EventLoop\Timer\TimerInterface; |
|
26 | +use React\Socket\Connection; |
|
27 | 27 | use React\Socket\ConnectionInterface; |
28 | 28 | |
29 | 29 | abstract class AbstractConnection |