|
@@ -96,7 +96,7 @@ discard block |
|
|
block discarded – undo |
|
96
|
96
|
$this->buildMessageProcessor(); |
|
97
|
97
|
|
|
98
|
98
|
// Some optimization |
|
99
|
|
- \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
|
99
|
+ \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
100
|
100
|
\set_time_limit(0); // It's by default on most server for cli apps but better be sure of that fact |
|
101
|
101
|
} |
|
102
|
102
|
|
|
@@ -106,13 +106,13 @@ discard block |
|
|
block discarded – undo |
|
106
|
106
|
*/ |
|
107
|
107
|
public function setMessageHandler($messageHandler, $uri = '*') |
|
108
|
108
|
{ |
|
109
|
|
- if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
|
109
|
+ if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
110
|
110
|
throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.'); |
|
111
|
111
|
} |
|
112
|
112
|
if (\is_string($messageHandler)) { |
|
113
|
113
|
try { |
|
114
|
114
|
$reflection = new \ReflectionClass($messageHandler); |
|
115
|
|
- if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
|
115
|
+ if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
116
|
116
|
throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface'); |
|
117
|
117
|
} |
|
118
|
118
|
} catch (\ReflectionException $e) { |
|
@@ -144,7 +144,7 @@ discard block |
|
|
block discarded – undo |
|
144
|
144
|
$this->getLogger()->info('Enabled ssl'); |
|
145
|
145
|
} |
|
146
|
146
|
|
|
147
|
|
- $this->server->on('connection', function ($socketStream) { |
|
|
147
|
+ $this->server->on('connection', function($socketStream) { |
|
148
|
148
|
$this->onNewConnection($socketStream); |
|
149
|
149
|
}); |
|
150
|
150
|
|
|
@@ -158,7 +158,7 @@ discard block |
|
|
block discarded – undo |
|
158
|
158
|
*/ |
|
159
|
159
|
private function onNewConnection(ConnectionInterface $socketStream) |
|
160
|
160
|
{ |
|
161
|
|
- $connection = new Connection($socketStream, function ($uri, Connection $connection) { |
|
|
161
|
+ $connection = new Connection($socketStream, function($uri, Connection $connection) { |
|
162
|
162
|
return $this->getMessageHandler($uri, $connection); |
|
163
|
163
|
}, $this->loop, $this->messageProcessor); |
|
164
|
164
|
|