@@ -76,14 +76,14 @@ |
||
76 | 76 | parent::bindWebSocketEvent(); |
77 | 77 | |
78 | 78 | if ($this->enableWebSocket) { |
79 | - $eventHandler = function ($method, array $params) { |
|
80 | - $this->callWithCatchException(function () use ($method, $params) { |
|
79 | + $eventHandler = function($method, array $params) { |
|
80 | + $this->callWithCatchException(function() use ($method, $params) { |
|
81 | 81 | $handler = $this->getWebSocketHandler(); |
82 | 82 | call_user_func_array([$handler, $method], $params); |
83 | 83 | }); |
84 | 84 | }; |
85 | 85 | |
86 | - $this->swoole->on('Open', function (WebSocketServer $server, SwooleRequest $request) use ($eventHandler) { |
|
86 | + $this->swoole->on('Open', function(WebSocketServer $server, SwooleRequest $request) use ($eventHandler) { |
|
87 | 87 | // Start Laravel's lifetime, then support session ...middleware. |
88 | 88 | $laravelRequest = $this->convertRequest($this->laravel, $request); |
89 | 89 | $this->laravel->bindRequest($laravelRequest); |
@@ -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); |
@@ -98,28 +98,28 @@ discard block |
||
98 | 98 | protected function bindWebSocketEvent() |
99 | 99 | { |
100 | 100 | if ($this->enableWebSocket) { |
101 | - $eventHandler = function ($method, array $params) { |
|
102 | - $this->callWithCatchException(function () use ($method, $params) { |
|
101 | + $eventHandler = function($method, array $params) { |
|
102 | + $this->callWithCatchException(function() use ($method, $params) { |
|
103 | 103 | $handler = $this->getWebSocketHandler(); |
104 | 104 | call_user_func_array([$handler, $method], $params); |
105 | 105 | }); |
106 | 106 | }; |
107 | 107 | |
108 | 108 | if (method_exists($this->getWebSocketHandler(true), 'onHandShake')) { |
109 | - $this->swoole->on('HandShake', function () use ($eventHandler) { |
|
109 | + $this->swoole->on('HandShake', function() use ($eventHandler) { |
|
110 | 110 | $eventHandler('onHandShake', func_get_args()); |
111 | 111 | }); |
112 | 112 | } |
113 | 113 | |
114 | - $this->swoole->on('Open', function () use ($eventHandler) { |
|
114 | + $this->swoole->on('Open', function() use ($eventHandler) { |
|
115 | 115 | $eventHandler('onOpen', func_get_args()); |
116 | 116 | }); |
117 | 117 | |
118 | - $this->swoole->on('Message', function () use ($eventHandler) { |
|
118 | + $this->swoole->on('Message', function() use ($eventHandler) { |
|
119 | 119 | $eventHandler('onMessage', func_get_args()); |
120 | 120 | }); |
121 | 121 | |
122 | - $this->swoole->on('Close', function (WebSocketServer $server, $fd, $reactorId) use ($eventHandler) { |
|
122 | + $this->swoole->on('Close', function(WebSocketServer $server, $fd, $reactorId) use ($eventHandler) { |
|
123 | 123 | $clientInfo = $server->getClientInfo($fd); |
124 | 124 | if (isset($clientInfo['websocket_status']) && $clientInfo['websocket_status'] === \WEBSOCKET_STATUS_FRAME) { |
125 | 125 | $eventHandler('onClose', func_get_args()); |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | $port->set(empty($socket['settings']) ? [] : $socket['settings']); |
148 | 148 | |
149 | 149 | $handlerClass = $socket['handler']; |
150 | - $eventHandler = function ($method, array $params) use ($port, $handlerClass) { |
|
150 | + $eventHandler = function($method, array $params) use ($port, $handlerClass) { |
|
151 | 151 | $handler = $this->getSocketHandler($port, $handlerClass); |
152 | 152 | if (method_exists($handler, $method)) { |
153 | - $this->callWithCatchException(function () use ($handler, $method, $params) { |
|
153 | + $this->callWithCatchException(function() use ($handler, $method, $params) { |
|
154 | 154 | call_user_func_array([$handler, $method], $params); |
155 | 155 | }); |
156 | 156 | } |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | 'BufferEmpty', |
169 | 169 | ]; |
170 | 170 | foreach ($events as $event) { |
171 | - $port->on($event, function () use ($event, $eventHandler) { |
|
172 | - $eventHandler('on' . $event, func_get_args()); |
|
171 | + $port->on($event, function() use ($event, $eventHandler) { |
|
172 | + $eventHandler('on'.$event, func_get_args()); |
|
173 | 173 | }); |
174 | 174 | } |
175 | 175 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | protected function bindSwooleTables() |
214 | 214 | { |
215 | - $tables = isset($this->conf['swoole_tables']) ? (array)$this->conf['swoole_tables'] : []; |
|
215 | + $tables = isset($this->conf['swoole_tables']) ? (array) $this->conf['swoole_tables'] : []; |
|
216 | 216 | foreach ($tables as $name => $table) { |
217 | 217 | $t = new Table($table['size']); |
218 | 218 | foreach ($table['column'] as $column) { |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | if (!($listener instanceof Listener)) { |
320 | 320 | throw new \InvalidArgumentException(sprintf('%s must extend the abstract class %s', $listenerClass, Listener::class)); |
321 | 321 | } |
322 | - $this->callWithCatchException(function () use ($listener) { |
|
322 | + $this->callWithCatchException(function() use ($listener) { |
|
323 | 323 | $listener->handle(); |
324 | 324 | }, [], $event->getTries()); |
325 | 325 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | protected function handleTask(Task $task) |
330 | 330 | { |
331 | - return $this->callWithCatchException(function () use ($task) { |
|
331 | + return $this->callWithCatchException(function() use ($task) { |
|
332 | 332 | $task->handle(); |
333 | 333 | return true; |
334 | 334 | }, [], $task->getTries()); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | protected function fireEvent($event, $interface, array $arguments) |
338 | 338 | { |
339 | 339 | if (isset($this->conf['event_handlers'][$event])) { |
340 | - $eventHandlers = (array)$this->conf['event_handlers'][$event]; |
|
340 | + $eventHandlers = (array) $this->conf['event_handlers'][$event]; |
|
341 | 341 | foreach ($eventHandlers as $eventHandler) { |
342 | 342 | if (!isset(class_implements($eventHandler)[$interface])) { |
343 | 343 | throw new \InvalidArgumentException(sprintf( |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | } |
350 | - $this->callWithCatchException(function () use ($eventHandler, $arguments) { |
|
350 | + $this->callWithCatchException(function() use ($eventHandler, $arguments) { |
|
351 | 351 | call_user_func_array([(new $eventHandler), 'handle'], $arguments); |
352 | 352 | }); |
353 | 353 | } |