@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $ip = isset($conf['listen_ip']) ? $conf['listen_ip'] : '127.0.0.1'; |
| 40 | 40 | $port = isset($conf['listen_port']) ? $conf['listen_port'] : 5200; |
| 41 | - $socketType = isset($conf['socket_type']) ? (int)$conf['socket_type'] : SWOOLE_SOCK_TCP; |
|
| 41 | + $socketType = isset($conf['socket_type']) ? (int) $conf['socket_type'] : SWOOLE_SOCK_TCP; |
|
| 42 | 42 | |
| 43 | 43 | if ($socketType === SWOOLE_SOCK_UNIX_STREAM) { |
| 44 | 44 | $socketDir = dirname($ip); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | protected function triggerWebSocketEvent($event, array $params) |
| 102 | 102 | { |
| 103 | - return $this->callWithCatchException(function () use ($event, $params) { |
|
| 103 | + return $this->callWithCatchException(function() use ($event, $params) { |
|
| 104 | 104 | $handler = $this->getWebSocketHandler(); |
| 105 | 105 | |
| 106 | 106 | if (method_exists($handler, $event)) { |
@@ -115,19 +115,19 @@ discard block |
||
| 115 | 115 | protected function bindWebSocketEvents() |
| 116 | 116 | { |
| 117 | 117 | if ($this->enableWebSocket) { |
| 118 | - $this->swoole->on('HandShake', function () { |
|
| 118 | + $this->swoole->on('HandShake', function() { |
|
| 119 | 119 | return $this->triggerWebSocketEvent('onHandShake', func_get_args()); |
| 120 | 120 | }); |
| 121 | 121 | |
| 122 | - $this->swoole->on('Open', function () { |
|
| 122 | + $this->swoole->on('Open', function() { |
|
| 123 | 123 | $this->triggerWebSocketEvent('onOpen', func_get_args()); |
| 124 | 124 | }); |
| 125 | 125 | |
| 126 | - $this->swoole->on('Message', function () { |
|
| 126 | + $this->swoole->on('Message', function() { |
|
| 127 | 127 | $this->triggerWebSocketEvent('onMessage', func_get_args()); |
| 128 | 128 | }); |
| 129 | 129 | |
| 130 | - $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) { |
|
| 130 | + $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) { |
|
| 131 | 131 | $clientInfo = $server->getClientInfo($fd); |
| 132 | 132 | if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) { |
| 133 | 133 | $this->triggerWebSocketEvent('onClose', func_get_args()); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | protected function triggerPortEvent(Port $port, $handlerClass, $event, array $params) |
| 141 | 141 | { |
| 142 | - return $this->callWithCatchException(function () use ($port, $handlerClass, $event, $params) { |
|
| 142 | + return $this->callWithCatchException(function() use ($port, $handlerClass, $event, $params) { |
|
| 143 | 143 | $handler = $this->getSocketHandler($port, $handlerClass); |
| 144 | 144 | |
| 145 | 145 | if (method_exists($handler, $event)) { |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | 'BufferEmpty', |
| 185 | 185 | ]; |
| 186 | 186 | foreach ($events as $event) { |
| 187 | - $port->on($event, function () use ($port, $handlerClass, $event) { |
|
| 188 | - $this->triggerPortEvent($port, $handlerClass, 'on' . $event, func_get_args()); |
|
| 187 | + $port->on($event, function() use ($port, $handlerClass, $event) { |
|
| 188 | + $this->triggerPortEvent($port, $handlerClass, 'on'.$event, func_get_args()); |
|
| 189 | 189 | }); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | protected function bindSwooleTables() |
| 226 | 226 | { |
| 227 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
| 227 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
| 228 | 228 | foreach ($tables as $name => $table) { |
| 229 | 229 | $t = new Table($table['size']); |
| 230 | 230 | foreach ($table['column'] as $column) { |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $headers = [ |
| 324 | 324 | 'Upgrade' => 'websocket', |
| 325 | 325 | 'Connection' => 'Upgrade', |
| 326 | - 'Sec-WebSocket-Accept' => base64_encode(sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
| 326 | + 'Sec-WebSocket-Accept' => base64_encode(sha1($secKey.'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)), |
|
| 327 | 327 | 'Sec-WebSocket-Version' => '13', |
| 328 | 328 | ]; |
| 329 | 329 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - $result = $this->callWithCatchException(function () use ($listener, $event) { |
|
| 373 | + $result = $this->callWithCatchException(function() use ($listener, $event) { |
|
| 374 | 374 | return $listener->handle($event); |
| 375 | 375 | }, [], $event->getTries()); |
| 376 | 376 | |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | protected function handleTask(Task $task) |
| 384 | 384 | { |
| 385 | - return $this->callWithCatchException(function () use ($task) { |
|
| 385 | + return $this->callWithCatchException(function() use ($task) { |
|
| 386 | 386 | $task->handle(); |
| 387 | 387 | return true; |
| 388 | 388 | }, [], $task->getTries()); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | protected function fireEvent($event, $interface, array $arguments) |
| 392 | 392 | { |
| 393 | 393 | if (isset($this->conf['event_handlers'][$event])) { |
| 394 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
| 394 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
| 395 | 395 | foreach ($eventHandlers as $eventHandler) { |
| 396 | 396 | if (!isset(class_implements($eventHandler)[$interface])) { |
| 397 | 397 | throw new \InvalidArgumentException(sprintf( |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | ) |
| 402 | 402 | ); |
| 403 | 403 | } |
| 404 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
| 404 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
| 405 | 405 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
| 406 | 406 | }); |
| 407 | 407 | } |