|
@@ -83,19 +83,19 @@ discard block |
|
|
block discarded – undo |
|
83
|
83
|
$this->buildMessageProcessor(); |
|
84
|
84
|
|
|
85
|
85
|
// Some optimization |
|
86
|
|
- \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
|
86
|
+ \gc_enable(); // As the process never stops, the garbage collector will be usefull, you may need to call it manually sometimes for performance purpose |
|
87
|
87
|
\set_time_limit(0); // It's by default on most server for cli apps but better be sure of that fact |
|
88
|
88
|
} |
|
89
|
89
|
|
|
90
|
90
|
public function setMessageHandler($messageHandler) |
|
91
|
91
|
{ |
|
92
|
|
- if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
|
92
|
+ if (!$messageHandler instanceof MessageHandlerInterface && !\is_string($messageHandler)) { |
|
93
|
93
|
throw new \InvalidArgumentException('The message handler must be an instance of MessageHandlerInterface or a string.'); |
|
94
|
94
|
} |
|
95
|
95
|
if (\is_string($messageHandler)) { |
|
96
|
96
|
try { |
|
97
|
97
|
$reflection = new \ReflectionClass($messageHandler); |
|
98
|
|
- if(!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
|
98
|
+ if (!$reflection->implementsInterface('Nekland\Woketo\Message\MessageHandlerInterface')) { |
|
99
|
99
|
throw new \InvalidArgumentException('The messageHandler must implement MessageHandlerInterface'); |
|
100
|
100
|
} |
|
101
|
101
|
} catch (\ReflectionException $e) { |
|
@@ -114,7 +114,7 @@ discard block |
|
|
block discarded – undo |
|
114
|
114
|
$this->loop = \React\EventLoop\Factory::create(); |
|
115
|
115
|
|
|
116
|
116
|
$socket = new \React\Socket\Server($this->loop); |
|
117
|
|
- $socket->on('connection', function ($socketStream) { |
|
|
117
|
+ $socket->on('connection', function($socketStream) { |
|
118
|
118
|
$this->onNewConnection($socketStream); |
|
119
|
119
|
}); |
|
120
|
120
|
$socket->listen($this->port); |