|
@@ -102,7 +102,7 @@ discard block |
|
|
block discarded – undo |
|
102
|
102
|
$this->buildMessageProcessor(); |
|
103
|
103
|
|
|
104
|
104
|
// Some optimization |
|
105
|
|
- \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
|
105
|
+ \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
106
|
106
|
\set_time_limit(0); // It's by default on most server for cli apps but better be sure of that fact |
|
107
|
107
|
} |
|
108
|
108
|
|
|
@@ -112,13 +112,13 @@ discard block |
|
|
block discarded – undo |
|
112
|
112
|
*/ |
|
113
|
113
|
public function setMessageHandler($messageHandler, $uri = '*') |
|
114
|
114
|
{ |
|
115
|
|
- if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
|
115
|
+ if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
116
|
116
|
throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.'); |
|
117
|
117
|
} |
|
118
|
118
|
if (\is_string($messageHandler)) { |
|
119
|
119
|
try { |
|
120
|
120
|
$reflection = new \ReflectionClass($messageHandler); |
|
121
|
|
- if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
|
121
|
+ if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
122
|
122
|
throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface'); |
|
123
|
123
|
} |
|
124
|
124
|
} catch (\ReflectionException $e) { |
|
@@ -150,7 +150,7 @@ discard block |
|
|
block discarded – undo |
|
150
|
150
|
$this->getLogger()->info('Enabled ssl'); |
|
151
|
151
|
} |
|
152
|
152
|
|
|
153
|
|
- $this->server->on('connection', function (ConnectionInterface $socketStream) { |
|
|
153
|
+ $this->server->on('connection', function(ConnectionInterface $socketStream) { |
|
154
|
154
|
$this->onNewConnection($socketStream); |
|
155
|
155
|
}); |
|
156
|
156
|
|
|
@@ -164,11 +164,11 @@ discard block |
|
|
block discarded – undo |
|
164
|
164
|
*/ |
|
165
|
165
|
private function onNewConnection(ConnectionInterface $socketStream) |
|
166
|
166
|
{ |
|
167
|
|
- $connection = new Connection($socketStream, function ($uri, Connection $connection) { |
|
|
167
|
+ $connection = new Connection($socketStream, function($uri, Connection $connection) { |
|
168
|
168
|
return $this->getMessageHandler($uri, $connection); |
|
169
|
169
|
}, $this->loop, $this->messageProcessor); |
|
170
|
170
|
|
|
171
|
|
- $socketStream->on('end', function () use($connection) { |
|
|
171
|
+ $socketStream->on('end', function() use($connection) { |
|
172
|
172
|
$this->onDisconnect($connection); |
|
173
|
173
|
}); |
|
174
|
174
|
|