@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $ip = isset($conf['listen_ip']) ? $conf['listen_ip'] : '127.0.0.1'; |
43 | 43 | $port = isset($conf['listen_port']) ? $conf['listen_port'] : 5200; |
44 | - $socketType = isset($conf['socket_type']) ? (int)$conf['socket_type'] : SWOOLE_SOCK_TCP; |
|
44 | + $socketType = isset($conf['socket_type']) ? (int) $conf['socket_type'] : SWOOLE_SOCK_TCP; |
|
45 | 45 | |
46 | 46 | if ($socketType === SWOOLE_SOCK_UNIX_STREAM) { |
47 | 47 | $socketDir = dirname($ip); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | protected function triggerWebSocketEvent($event, array $params) |
99 | 99 | { |
100 | - return $this->callWithCatchException(function () use ($event, $params) { |
|
100 | + return $this->callWithCatchException(function() use ($event, $params) { |
|
101 | 101 | $handler = $this->getWebSocketHandler(); |
102 | 102 | |
103 | 103 | if (method_exists($handler, $event)) { |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | protected function bindWebSocketEvents() |
117 | 117 | { |
118 | 118 | if ($this->enableWebSocket) { |
119 | - $this->swoole->on('HandShake', function () { |
|
119 | + $this->swoole->on('HandShake', function() { |
|
120 | 120 | return $this->triggerWebSocketEvent('onHandShake', func_get_args()); |
121 | 121 | }); |
122 | 122 | |
123 | - $this->swoole->on('Open', function () { |
|
123 | + $this->swoole->on('Open', function() { |
|
124 | 124 | $this->triggerWebSocketEvent('onOpen', func_get_args()); |
125 | 125 | }); |
126 | 126 | |
127 | - $this->swoole->on('Message', function () { |
|
127 | + $this->swoole->on('Message', function() { |
|
128 | 128 | $this->triggerWebSocketEvent('onMessage', func_get_args()); |
129 | 129 | }); |
130 | 130 | |
131 | - $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) { |
|
131 | + $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) { |
|
132 | 132 | $clientInfo = $server->getClientInfo($fd); |
133 | 133 | if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) { |
134 | 134 | $this->triggerWebSocketEvent('onClose', func_get_args()); |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | $port->set(empty($socket['settings']) ? [] : $socket['settings']); |
157 | 157 | |
158 | 158 | $handlerClass = $socket['handler']; |
159 | - $eventHandler = function ($method, array $params) use ($port, $handlerClass) { |
|
159 | + $eventHandler = function($method, array $params) use ($port, $handlerClass) { |
|
160 | 160 | $handler = $this->getSocketHandler($port, $handlerClass); |
161 | 161 | if (method_exists($handler, $method)) { |
162 | - $this->callWithCatchException(function () use ($handler, $method, $params) { |
|
162 | + $this->callWithCatchException(function() use ($handler, $method, $params) { |
|
163 | 163 | call_user_func_array([$handler, $method], $params); |
164 | 164 | }); |
165 | 165 | } |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | 'BufferEmpty', |
178 | 178 | ]; |
179 | 179 | foreach ($events as $event) { |
180 | - $port->on($event, function () use ($event, $eventHandler) { |
|
181 | - return $eventHandler('on' . $event, func_get_args()); |
|
180 | + $port->on($event, function() use ($event, $eventHandler) { |
|
181 | + return $eventHandler('on'.$event, func_get_args()); |
|
182 | 182 | }); |
183 | 183 | } |
184 | 184 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | protected function bindSwooleTables() |
219 | 219 | { |
220 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
220 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
221 | 221 | foreach ($tables as $name => $table) { |
222 | 222 | $t = new Table($table['size']); |
223 | 223 | foreach ($table['column'] as $column) { |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $headers = [ |
315 | 315 | 'Upgrade' => 'websocket', |
316 | 316 | 'Connection' => 'Upgrade', |
317 | - 'Sec-WebSocket-Accept' => base64_encode(sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
317 | + 'Sec-WebSocket-Accept' => base64_encode(sha1($secKey.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
318 | 318 | 'Sec-WebSocket-Version' => '13', |
319 | 319 | ]; |
320 | 320 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | if (!($listener instanceof Listener)) { |
362 | 362 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
363 | 363 | } |
364 | - $this->callWithCatchException(function () use ($listener) { |
|
364 | + $this->callWithCatchException(function() use ($listener) { |
|
365 | 365 | $listener->handle(); |
366 | 366 | }, [], $event->getTries()); |
367 | 367 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | protected function handleTask(Task $task) |
372 | 372 | { |
373 | - return $this->callWithCatchException(function () use ($task) { |
|
373 | + return $this->callWithCatchException(function() use ($task) { |
|
374 | 374 | $task->handle(); |
375 | 375 | return true; |
376 | 376 | }, [], $task->getTries()); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | protected function fireEvent($event, $interface, array $arguments) |
380 | 380 | { |
381 | 381 | if (isset($this->conf['event_handlers'][$event])) { |
382 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
382 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
383 | 383 | foreach ($eventHandlers as $eventHandler) { |
384 | 384 | if (!isset(class_implements($eventHandler)[$interface])) { |
385 | 385 | throw new \InvalidArgumentException(sprintf( |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | ) |
390 | 390 | ); |
391 | 391 | } |
392 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
392 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
393 | 393 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
394 | 394 | }); |
395 | 395 | } |