@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function make(?callable $callback = null) |
64 | 64 | { |
65 | - $mcb = function ($type, $buffer) use ($callback) { |
|
66 | - if (! $this->locked && AppProcess::OUT === $type && $event = FSEventParser::toEvent($buffer)) { |
|
65 | + $mcb = function($type, $buffer) use ($callback) { |
|
66 | + if (!$this->locked && AppProcess::OUT === $type && $event = FSEventParser::toEvent($buffer)) { |
|
67 | 67 | $this->locked = true; |
68 | 68 | ($callback) ? $callback($event) : null; |
69 | 69 | $this->locked = false; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | }; |
73 | 73 | |
74 | - return new SwooleProcess(function () use ($mcb) { |
|
74 | + return new SwooleProcess(function() use ($mcb) { |
|
75 | 75 | (new AppProcess($this->configure()))->setTimeout(0)->run($mcb); |
76 | 76 | }, false, false); |
77 | 77 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // enable sandbox |
67 | 67 | $sandbox->enable(); |
68 | 68 | // check if socket.io connection established |
69 | - if (! $this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
69 | + if (!$this->websocketHandler->onOpen($swooleRequest->fd, $illuminateRequest)) { |
|
70 | 70 | return; |
71 | 71 | } |
72 | 72 | // trigger 'connect' websocket event |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function onClose($server, $fd, $reactorId) |
132 | 132 | { |
133 | - if (! $this->isServerWebsocket($fd) || ! $server instanceof Websocket) { |
|
133 | + if (!$this->isServerWebsocket($fd) || !$server instanceof Websocket) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function isWebsocketPushPacket($packet) |
160 | 160 | { |
161 | - if ( !is_array($packet)) { |
|
161 | + if (!is_array($packet)) { |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $payload = $this->payloadParser->encode($push->getEvent(), $push->getMessage()); |
181 | 181 | |
182 | 182 | // attach sender if not broadcast |
183 | - if (! $push->isBroadcast() && $push->getSender() && ! $push->hasOwnDescriptor()) { |
|
183 | + if (!$push->isBroadcast() && $push->getSender() && !$push->hasOwnDescriptor()) { |
|
184 | 184 | $push->addDescriptor($push->getSender()); |
185 | 185 | } |
186 | 186 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // push message to designated fds |
193 | 193 | foreach ($push->getDescriptors() as $descriptor) { |
194 | - if ($server->exist($descriptor) || ! $push->isBroadcastToDescriptor((int) $descriptor)) { |
|
194 | + if ($server->exist($descriptor) || !$push->isBroadcastToDescriptor((int) $descriptor)) { |
|
195 | 195 | $server->push($descriptor, $payload, $push->getOpcode()); |
196 | 196 | } |
197 | 197 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | protected function filterWebsocket(array $descriptors): array |
260 | 260 | { |
261 | - $callback = function ($descriptor) { |
|
261 | + $callback = function($descriptor) { |
|
262 | 262 | return $this->isServerWebsocket($descriptor); |
263 | 263 | }; |
264 | 264 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | { |
275 | 275 | $handlerClass = $this->container->make('config')->get('swoole_websocket.handler'); |
276 | 276 | |
277 | - if (! $handlerClass) { |
|
277 | + if (!$handlerClass) { |
|
278 | 278 | throw new WebsocketNotSetInConfigException; |
279 | 279 | } |
280 | 280 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | protected function bindRoom(): void |
323 | 323 | { |
324 | - $this->app->singleton(RoomContract::class, function (Container $container) { |
|
324 | + $this->app->singleton(RoomContract::class, function(Container $container) { |
|
325 | 325 | $config = $container->make('config'); |
326 | 326 | $driver = $config->get('swoole_websocket.default'); |
327 | 327 | $settings = $config->get("swoole_websocket.settings.{$driver}"); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | protected function bindWebsocket() |
340 | 340 | { |
341 | - $this->app->singleton(Websocket::class, function (Container $app) { |
|
341 | + $this->app->singleton(Websocket::class, function(Container $app) { |
|
342 | 342 | return new Websocket($app->make(RoomContract::class), new Pipeline($app)); |
343 | 343 | }); |
344 | 344 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $routePath = $this->container->make('config') |
354 | 354 | ->get('swoole_websocket.route_file'); |
355 | 355 | |
356 | - if (! file_exists($routePath)) { |
|
356 | + if (!file_exists($routePath)) { |
|
357 | 357 | $routePath = __DIR__ . '/../../routes/websocket.php'; |
358 | 358 | } |
359 | 359 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | protected function isWebsocketPushPayload($payload): bool |
391 | 391 | { |
392 | - if (! is_array($payload)) { |
|
392 | + if (!is_array($payload)) { |
|
393 | 393 | return false; |
394 | 394 | } |
395 | 395 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | protected function isSwooleQueuePacket($packet) |
16 | 16 | { |
17 | - if (! is_string($packet)) { |
|
17 | + if (!is_string($packet)) { |
|
18 | 18 | return false; |
19 | 19 | } |
20 | 20 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function setRedis(?RedisClient $redis = null) |
59 | 59 | { |
60 | - if (! $redis) { |
|
60 | + if (!$redis) { |
|
61 | 61 | $server = Arr::get($this->config, 'server', []); |
62 | 62 | $options = Arr::get($this->config, 'options', []); |
63 | 63 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $this->checkTable($table); |
140 | 140 | $redisKey = $this->getKey($key, $table); |
141 | 141 | |
142 | - $this->redis->pipeline(function (Pipeline $pipe) use ($redisKey, $values) { |
|
142 | + $this->redis->pipeline(function(Pipeline $pipe) use ($redisKey, $values) { |
|
143 | 143 | foreach ($values as $value) { |
144 | 144 | $pipe->sadd($redisKey, $value); |
145 | 145 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->checkTable($table); |
163 | 163 | $redisKey = $this->getKey($key, $table); |
164 | 164 | |
165 | - $this->redis->pipeline(function (Pipeline $pipe) use ($redisKey, $values) { |
|
165 | + $this->redis->pipeline(function(Pipeline $pipe) use ($redisKey, $values) { |
|
166 | 166 | foreach ($values as $value) { |
167 | 167 | $pipe->srem($redisKey, $value); |
168 | 168 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function checkTable(string $table) |
204 | 204 | { |
205 | - if (! in_array($table, [RoomContract::ROOMS_KEY, RoomContract::DESCRIPTORS_KEY])) { |
|
205 | + if (!in_array($table, [RoomContract::ROOMS_KEY, RoomContract::DESCRIPTORS_KEY])) { |
|
206 | 206 | throw new \InvalidArgumentException("Invalid table name: `{$table}`."); |
207 | 207 | } |
208 | 208 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | foreach ($rooms as $room) { |
88 | 88 | $fds = $this->getClients($room); |
89 | 89 | |
90 | - if (! in_array($fd, $fds)) { |
|
90 | + if (!in_array($fd, $fds)) { |
|
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function checkTable(string $table) |
208 | 208 | { |
209 | - if (! property_exists($this, $table) || ! $this->$table instanceof Table) { |
|
209 | + if (!property_exists($this, $table) || !$this->$table instanceof Table) { |
|
210 | 210 | throw new \InvalidArgumentException("Invalid table name: `{$table}`."); |
211 | 211 | } |
212 | 212 | } |