@@ -26,7 +26,7 @@ |
||
26 | 26 | // and the values are on odd indexes. This way, we know which |
27 | 27 | // ones are keys and which ones are values and their get combined |
28 | 28 | // later to form the key => value array. |
29 | - [$keys, $values] = collect($list)->partition(function ($value, $key) { |
|
29 | + [$keys, $values] = collect($list)->partition(function($value, $key) { |
|
30 | 30 | return $key % 2 === 0; |
31 | 31 | }); |
32 | 32 |
@@ -16,14 +16,14 @@ |
||
16 | 16 | */ |
17 | 17 | public function __invoke(Request $request) |
18 | 18 | { |
19 | - if (! Str::startsWith($request->channelName, 'presence-')) { |
|
19 | + if (!Str::startsWith($request->channelName, 'presence-')) { |
|
20 | 20 | return new HttpException(400, "Invalid presence channel `{$request->channelName}`"); |
21 | 21 | } |
22 | 22 | |
23 | 23 | return $this->channelManager |
24 | 24 | ->getChannelMembers($request->appId, $request->channelName) |
25 | - ->then(function ($members) { |
|
26 | - $users = collect($members)->map(function ($user) { |
|
25 | + ->then(function($members) { |
|
26 | + $users = collect($members)->map(function($user) { |
|
27 | 27 | return ['id' => $user->user_id]; |
28 | 28 | })->values()->toArray(); |
29 | 29 |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $this->requestBuffer = (string) $request->getBody(); |
87 | 87 | |
88 | - if (! $this->verifyContentLength()) { |
|
88 | + if (!$this->verifyContentLength()) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | $this->requestBuffer .= $msg; |
105 | 105 | |
106 | - if (! $this->verifyContentLength()) { |
|
106 | + if (!$this->verifyContentLength()) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function onError(ConnectionInterface $connection, Exception $exception) |
132 | 132 | { |
133 | - if (! $exception instanceof HttpException) { |
|
133 | + if (!$exception instanceof HttpException) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function findContentLength(array $headers): int |
153 | 153 | { |
154 | - return Collection::make($headers)->first(function ($values, $header) { |
|
154 | + return Collection::make($headers)->first(function($values, $header) { |
|
155 | 155 | return strtolower($header) === 'content-length'; |
156 | 156 | })[0] ?? 0; |
157 | 157 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | // Allow for async IO in the controller action |
194 | 194 | if ($response instanceof PromiseInterface) { |
195 | - $response->then(function ($response) use ($connection) { |
|
195 | + $response->then(function($response) use ($connection) { |
|
196 | 196 | $this->sendAndClose($connection, $response); |
197 | 197 | }); |
198 | 198 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function ensureValidAppId($appId) |
230 | 230 | { |
231 | - if (! $appId || ! $this->app = App::findById($appId)) { |
|
231 | + if (!$appId || !$this->app = App::findById($appId)) { |
|
232 | 232 | throw new HttpException(401, "Unknown app id `{$appId}` provided."); |
233 | 233 | } |
234 | 234 |
@@ -26,13 +26,13 @@ |
||
26 | 26 | |
27 | 27 | return $this->channelManager |
28 | 28 | ->getGlobalConnectionsCount($request->appId, $request->channelName) |
29 | - ->then(function ($connectionsCount) use ($request) { |
|
29 | + ->then(function($connectionsCount) use ($request) { |
|
30 | 30 | // For the presence channels, we need a slightly different response |
31 | 31 | // that need an additional call. |
32 | 32 | if (Str::startsWith($request->channelName, 'presence-')) { |
33 | 33 | return $this->channelManager |
34 | 34 | ->getChannelsMembersCount($request->appId, [$request->channelName]) |
35 | - ->then(function ($channelMembers) use ($connectionsCount, $request) { |
|
35 | + ->then(function($channelMembers) use ($connectionsCount, $request) { |
|
36 | 36 | return [ |
37 | 37 | 'occupied' => $connectionsCount > 0, |
38 | 38 | 'subscription_count' => $connectionsCount, |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $this->channelManager->getStatsRedisHash($appId, null), |
86 | 86 | 'current_connections_count', 1 |
87 | 87 | ) |
88 | - ->then(function ($currentConnectionsCount) use ($appId) { |
|
88 | + ->then(function($currentConnectionsCount) use ($appId) { |
|
89 | 89 | // Get the peak connections count from Redis. |
90 | 90 | $this->channelManager |
91 | 91 | ->getPublishClient() |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->channelManager->getStatsRedisHash($appId, null), |
94 | 94 | 'peak_connections_count' |
95 | 95 | ) |
96 | - ->then(function ($currentPeakConnectionCount) use ($currentConnectionsCount, $appId) { |
|
96 | + ->then(function($currentPeakConnectionCount) use ($currentConnectionsCount, $appId) { |
|
97 | 97 | // Extract the greatest number between the current peak connection count |
98 | 98 | // and the current connection number. |
99 | 99 | $peakConnectionsCount = is_null($currentPeakConnectionCount) |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | // Decrement the current connections count by 1. |
123 | 123 | $this->ensureAppIsInSet($appId) |
124 | 124 | ->hincrby($this->channelManager->getStatsRedisHash($appId, null), 'current_connections_count', -1) |
125 | - ->then(function ($currentConnectionsCount) use ($appId) { |
|
125 | + ->then(function($currentConnectionsCount) use ($appId) { |
|
126 | 126 | // Get the peak connections count from Redis. |
127 | 127 | $this->channelManager |
128 | 128 | ->getPublishClient() |
129 | 129 | ->hget($this->channelManager->getStatsRedisHash($appId, null), 'peak_connections_count') |
130 | - ->then(function ($currentPeakConnectionCount) use ($currentConnectionsCount, $appId) { |
|
130 | + ->then(function($currentPeakConnectionCount) use ($currentConnectionsCount, $appId) { |
|
131 | 131 | // Extract the greatest number between the current peak connection count |
132 | 132 | // and the current connection number. |
133 | 133 | $peakConnectionsCount = is_null($currentPeakConnectionCount) |
@@ -152,17 +152,17 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function save() |
154 | 154 | { |
155 | - $this->lock()->get(function () { |
|
155 | + $this->lock()->get(function() { |
|
156 | 156 | $this->channelManager |
157 | 157 | ->getPublishClient() |
158 | 158 | ->smembers(static::$redisSetName) |
159 | - ->then(function ($members) { |
|
159 | + ->then(function($members) { |
|
160 | 160 | foreach ($members as $appId) { |
161 | 161 | $this->channelManager |
162 | 162 | ->getPublishClient() |
163 | 163 | ->hgetall($this->channelManager->getStatsRedisHash($appId, null)) |
164 | - ->then(function ($list) use ($appId) { |
|
165 | - if (! $list) { |
|
164 | + ->then(function($list) use ($appId) { |
|
165 | + if (!$list) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | $this->channelManager |
180 | 180 | ->getGlobalConnectionsCount($appId) |
181 | - ->then(function ($currentConnectionsCount) use ($appId) { |
|
181 | + ->then(function($currentConnectionsCount) use ($appId) { |
|
182 | 182 | $currentConnectionsCount === 0 || is_null($currentConnectionsCount) |
183 | 183 | ? $this->resetAppTraces($appId) |
184 | 184 | : $this->resetStatistics($appId, $currentConnectionsCount); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function flush() |
198 | 198 | { |
199 | - $this->getStatistics()->then(function ($statistics) { |
|
199 | + $this->getStatistics()->then(function($statistics) { |
|
200 | 200 | foreach ($statistics as $appId => $statistic) { |
201 | 201 | $this->resetAppTraces($appId); |
202 | 202 | } |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | return $this->channelManager |
214 | 214 | ->getPublishClient() |
215 | 215 | ->smembers(static::$redisSetName) |
216 | - ->then(function ($members) { |
|
216 | + ->then(function($members) { |
|
217 | 217 | $appsWithStatistics = []; |
218 | 218 | |
219 | 219 | foreach ($members as $appId) { |
220 | 220 | $this->channelManager |
221 | 221 | ->getPublishClient() |
222 | 222 | ->hgetall($this->channelManager->getStatsRedisHash($appId, null)) |
223 | - ->then(function ($list) use ($appId, &$appsWithStatistics) { |
|
223 | + ->then(function($list) use ($appId, &$appsWithStatistics) { |
|
224 | 224 | $appsWithStatistics[$appId] = $this->arrayToStatisticInstance( |
225 | 225 | $appId, Helpers::redisListToArray($list) |
226 | 226 | ); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | return $this->channelManager |
243 | 243 | ->getPublishClient() |
244 | 244 | ->hgetall($this->channelManager->getStatsRedisHash($appId, null)) |
245 | - ->then(function ($list) use ($appId) { |
|
245 | + ->then(function($list) use ($appId) { |
|
246 | 246 | return $this->arrayToStatisticInstance( |
247 | 247 | $appId, Helpers::redisListToArray($list) |
248 | 248 | ); |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function save() |
92 | 92 | { |
93 | - $this->getStatistics()->then(function ($statistics) { |
|
93 | + $this->getStatistics()->then(function($statistics) { |
|
94 | 94 | foreach ($statistics as $appId => $statistic) { |
95 | - if (! $statistic->isEnabled()) { |
|
95 | + if (!$statistic->isEnabled()) { |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | $this->channelManager |
108 | 108 | ->getGlobalConnectionsCount($appId) |
109 | - ->then(function ($connections) use ($statistic) { |
|
109 | + ->then(function($connections) use ($statistic) { |
|
110 | 110 | $statistic->reset( |
111 | 111 | is_null($connections) ? 0 : $connections |
112 | 112 | ); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | protected function findOrMake($appId): Statistic |
170 | 170 | { |
171 | - if (! isset($this->statistics[$appId])) { |
|
171 | + if (!isset($this->statistics[$appId])) { |
|
172 | 172 | $this->statistics[$appId] = Statistic::new($appId); |
173 | 173 | } |
174 | 174 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public static function delete(Carbon $moment, $appId = null): int |
41 | 41 | { |
42 | 42 | return static::$model::where('created_at', '<', $moment->toDateTimeString()) |
43 | - ->when(! is_null($appId), function ($query) use ($appId) { |
|
43 | + ->when(!is_null($appId), function($query) use ($appId) { |
|
44 | 44 | return $query->whereAppId($appId); |
45 | 45 | }) |
46 | 46 | ->delete(); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | public function getRawRecords(callable $processQuery = null) |
56 | 56 | { |
57 | 57 | return static::$model::query() |
58 | - ->when(! is_null($processQuery), function ($query) use ($processQuery) { |
|
58 | + ->when(!is_null($processQuery), function($query) use ($processQuery) { |
|
59 | 59 | return call_user_func($processQuery, $query); |
60 | - }, function ($query) { |
|
60 | + }, function($query) { |
|
61 | 61 | return $query->latest()->limit(120); |
62 | 62 | })->get(); |
63 | 63 | } |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | public function getRecords(callable $processQuery = null, callable $processCollection = null): array |
73 | 73 | { |
74 | 74 | return $this->getRawRecords($processQuery) |
75 | - ->when(! is_null($processCollection), function ($collection) use ($processCollection) { |
|
75 | + ->when(!is_null($processCollection), function($collection) use ($processCollection) { |
|
76 | 76 | return call_user_func($processCollection, $collection); |
77 | 77 | }) |
78 | - ->map(function (Model $statistic) { |
|
78 | + ->map(function(Model $statistic) { |
|
79 | 79 | return $this->statisticToArray($statistic); |
80 | 80 | }) |
81 | 81 | ->toArray(); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function configureManagers() |
108 | 108 | { |
109 | - $this->laravel->singleton(ChannelManager::class, function ($app) { |
|
109 | + $this->laravel->singleton(ChannelManager::class, function($app) { |
|
110 | 110 | $config = $app['config']['websockets']; |
111 | 111 | $mode = $config['replication']['mode'] ?? 'local'; |
112 | 112 | |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function configureStatistics() |
126 | 126 | { |
127 | - if (! $this->option('disable-statistics')) { |
|
127 | + if (!$this->option('disable-statistics')) { |
|
128 | 128 | $intervalInSeconds = $this->option('statistics-interval') ?: config('websockets.statistics.interval_in_seconds', 3600); |
129 | 129 | |
130 | - $this->loop->addPeriodicTimer($intervalInSeconds, function () { |
|
130 | + $this->loop->addPeriodicTimer($intervalInSeconds, function() { |
|
131 | 131 | $this->line('Saving statistics...'); |
132 | 132 | |
133 | 133 | StatisticsCollectorFacade::save(); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | { |
145 | 145 | $this->lastRestart = $this->getLastRestart(); |
146 | 146 | |
147 | - $this->loop->addPeriodicTimer(10, function () { |
|
147 | + $this->loop->addPeriodicTimer(10, function() { |
|
148 | 148 | if ($this->getLastRestart() !== $this->lastRestart) { |
149 | 149 | $this->triggerSoftShutdown(); |
150 | 150 | } |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | // to receive new connections, close the current connections, |
174 | 174 | // then stopping the loop. |
175 | 175 | |
176 | - if (! extension_loaded('pcntl')) { |
|
176 | + if (!extension_loaded('pcntl')) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | - $this->loop->addSignal(SIGTERM, function () { |
|
180 | + $this->loop->addSignal(SIGTERM, function() { |
|
181 | 181 | $this->line('Closing existing connections...'); |
182 | 182 | |
183 | 183 | $this->triggerSoftShutdown(); |
184 | 184 | }); |
185 | 185 | |
186 | - $this->loop->addSignal(SIGINT, function () { |
|
186 | + $this->loop->addSignal(SIGINT, function() { |
|
187 | 187 | $this->line('Closing existing connections...'); |
188 | 188 | |
189 | 189 | $this->triggerSoftShutdown(); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function configurePongTracker() |
200 | 200 | { |
201 | - $this->loop->addPeriodicTimer(10, function () { |
|
201 | + $this->loop->addPeriodicTimer(10, function() { |
|
202 | 202 | $this->laravel |
203 | 203 | ->make(ChannelManager::class) |
204 | 204 | ->removeObsoleteConnections(); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function configureHttpLogger() |
214 | 214 | { |
215 | - $this->laravel->singleton(HttpLogger::class, function ($app) { |
|
215 | + $this->laravel->singleton(HttpLogger::class, function($app) { |
|
216 | 216 | return (new HttpLogger($this->output)) |
217 | 217 | ->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false)) |
218 | 218 | ->verbose($this->output->isVerbose()); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function configureMessageLogger() |
228 | 228 | { |
229 | - $this->laravel->singleton(WebSocketsLogger::class, function ($app) { |
|
229 | + $this->laravel->singleton(WebSocketsLogger::class, function($app) { |
|
230 | 230 | return (new WebSocketsLogger($this->output)) |
231 | 231 | ->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false)) |
232 | 232 | ->verbose($this->output->isVerbose()); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | protected function configureConnectionLogger() |
242 | 242 | { |
243 | - $this->laravel->bind(ConnectionLogger::class, function ($app) { |
|
243 | + $this->laravel->bind(ConnectionLogger::class, function($app) { |
|
244 | 244 | return (new ConnectionLogger($this->output)) |
245 | 245 | ->enable($app['config']['app']['debug'] ?? false) |
246 | 246 | ->verbose($this->output->isVerbose()); |
@@ -310,12 +310,12 @@ discard block |
||
310 | 310 | // Get all local connections and close them. They will |
311 | 311 | // be automatically be unsubscribed from all channels. |
312 | 312 | $channelManager->getLocalConnections() |
313 | - ->then(function ($connections) { |
|
313 | + ->then(function($connections) { |
|
314 | 314 | foreach ($connections as $connection) { |
315 | 315 | $connection->close(); |
316 | 316 | } |
317 | 317 | }) |
318 | - ->then(function () { |
|
318 | + ->then(function() { |
|
319 | 319 | $this->loop->stop(); |
320 | 320 | }); |
321 | 321 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->publishClient = $factory->createLazyClient($connectionUri); |
72 | 72 | $this->subscribeClient = $factory->createLazyClient($connectionUri); |
73 | 73 | |
74 | - $this->subscribeClient->on('message', function ($channel, $payload) { |
|
74 | + $this->subscribeClient->on('message', function($channel, $payload) { |
|
75 | 75 | $this->onMessage($channel, $payload); |
76 | 76 | }); |
77 | 77 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | public function unsubscribeFromAllChannels(ConnectionInterface $connection): PromiseInterface |
100 | 100 | { |
101 | 101 | return $this->getGlobalChannels($connection->app->id) |
102 | - ->then(function ($channels) use ($connection) { |
|
102 | + ->then(function($channels) use ($connection) { |
|
103 | 103 | foreach ($channels as $channel) { |
104 | 104 | $this->unsubscribeFromChannel($connection, $channel, new stdClass); |
105 | 105 | } |
106 | 106 | }) |
107 | - ->then(function () use ($connection) { |
|
107 | + ->then(function() use ($connection) { |
|
108 | 108 | return parent::unsubscribeFromAllChannels($connection); |
109 | 109 | }); |
110 | 110 | } |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | public function subscribeToChannel(ConnectionInterface $connection, string $channelName, stdClass $payload): PromiseInterface |
121 | 121 | { |
122 | 122 | return $this->subscribeToTopic($connection->app->id, $channelName) |
123 | - ->then(function () use ($connection) { |
|
123 | + ->then(function() use ($connection) { |
|
124 | 124 | return $this->addConnectionToSet($connection, Carbon::now()); |
125 | 125 | }) |
126 | - ->then(function () use ($connection, $channelName) { |
|
126 | + ->then(function() use ($connection, $channelName) { |
|
127 | 127 | return $this->addChannelToSet($connection->app->id, $channelName); |
128 | 128 | }) |
129 | - ->then(function () use ($connection, $channelName) { |
|
129 | + ->then(function() use ($connection, $channelName) { |
|
130 | 130 | return $this->incrementSubscriptionsCount($connection->app->id, $channelName, 1); |
131 | 131 | }) |
132 | - ->then(function () use ($connection, $channelName, $payload) { |
|
132 | + ->then(function() use ($connection, $channelName, $payload) { |
|
133 | 133 | return parent::subscribeToChannel($connection, $channelName, $payload); |
134 | 134 | }); |
135 | 135 | } |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | public function unsubscribeFromChannel(ConnectionInterface $connection, string $channelName, stdClass $payload): PromiseInterface |
146 | 146 | { |
147 | 147 | return parent::unsubscribeFromChannel($connection, $channelName, $payload) |
148 | - ->then(function () use ($connection, $channelName) { |
|
148 | + ->then(function() use ($connection, $channelName) { |
|
149 | 149 | return $this->decrementSubscriptionsCount($connection->app->id, $channelName); |
150 | 150 | }) |
151 | - ->then(function ($count) use ($connection, $channelName) { |
|
151 | + ->then(function($count) use ($connection, $channelName) { |
|
152 | 152 | $this->removeConnectionFromSet($connection); |
153 | 153 | // If the total connections count gets to 0 after unsubscribe, |
154 | 154 | // try again to check & unsubscribe from the PubSub topic if needed. |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function subscribeToApp($appId): PromiseInterface |
170 | 170 | { |
171 | 171 | return $this->subscribeToTopic($appId) |
172 | - ->then(function () use ($appId) { |
|
172 | + ->then(function() use ($appId) { |
|
173 | 173 | return $this->incrementSubscriptionsCount($appId); |
174 | 174 | }); |
175 | 175 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | public function unsubscribeFromApp($appId): PromiseInterface |
185 | 185 | { |
186 | 186 | return $this->unsubscribeFromTopic($appId) |
187 | - ->then(function () use ($appId) { |
|
187 | + ->then(function() use ($appId) { |
|
188 | 188 | return $this->decrementSubscriptionsCount($appId); |
189 | 189 | }); |
190 | 190 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | return $this->publishClient |
203 | 203 | ->hget($this->getStatsRedisHash($appId, $channelName), 'connections') |
204 | - ->then(function ($count) { |
|
204 | + ->then(function($count) { |
|
205 | 205 | return is_null($count) ? 0 : (int) $count; |
206 | 206 | }); |
207 | 207 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | return $this->publishClient |
226 | 226 | ->publish($this->getRedisTopicName($appId, $channel), json_encode($payload)) |
227 | - ->then(function () use ($appId, $socketId, $channel, $payload, $serverId) { |
|
227 | + ->then(function() use ($appId, $socketId, $channel, $payload, $serverId) { |
|
228 | 228 | return parent::broadcastAcrossServers($appId, $socketId, $channel, $payload, $serverId); |
229 | 229 | }); |
230 | 230 | } |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | public function userJoinedPresenceChannel(ConnectionInterface $connection, stdClass $user, string $channel, stdClass $payload): PromiseInterface |
242 | 242 | { |
243 | 243 | return $this->storeUserData($connection->app->id, $channel, $connection->socketId, json_encode($user)) |
244 | - ->then(function () use ($connection, $channel, $user) { |
|
244 | + ->then(function() use ($connection, $channel, $user) { |
|
245 | 245 | return $this->addUserSocket($connection->app->id, $channel, $user, $connection->socketId); |
246 | 246 | }) |
247 | - ->then(function () use ($connection, $user, $channel, $payload) { |
|
247 | + ->then(function() use ($connection, $user, $channel, $payload) { |
|
248 | 248 | return parent::userJoinedPresenceChannel($connection, $user, $channel, $payload); |
249 | 249 | }); |
250 | 250 | } |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | public function userLeftPresenceChannel(ConnectionInterface $connection, stdClass $user, string $channel): PromiseInterface |
262 | 262 | { |
263 | 263 | return $this->removeUserData($connection->app->id, $channel, $connection->socketId) |
264 | - ->then(function () use ($connection, $channel, $user) { |
|
264 | + ->then(function() use ($connection, $channel, $user) { |
|
265 | 265 | return $this->removeUserSocket($connection->app->id, $channel, $user, $connection->socketId); |
266 | 266 | }) |
267 | - ->then(function () use ($connection, $user, $channel) { |
|
267 | + ->then(function() use ($connection, $user, $channel) { |
|
268 | 268 | return parent::userLeftPresenceChannel($connection, $user, $channel); |
269 | 269 | }); |
270 | 270 | } |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | { |
281 | 281 | return $this->publishClient |
282 | 282 | ->hgetall($this->getUsersRedisHash($appId, $channel)) |
283 | - ->then(function ($list) { |
|
284 | - return collect(Helpers::redisListToArray($list))->map(function ($user) { |
|
283 | + ->then(function($list) { |
|
284 | + return collect(Helpers::redisListToArray($list))->map(function($user) { |
|
285 | 285 | return json_decode($user); |
286 | 286 | })->unique('user_id')->toArray(); |
287 | 287 | }); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | return $this->publishClient->exec() |
322 | - ->then(function ($data) use ($channelNames) { |
|
322 | + ->then(function($data) use ($channelNames) { |
|
323 | 323 | return array_combine($channelNames, $data); |
324 | 324 | }); |
325 | 325 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | { |
350 | 350 | // This will update the score with the current timestamp. |
351 | 351 | return $this->addConnectionToSet($connection, Carbon::now()) |
352 | - ->then(function () use ($connection) { |
|
352 | + ->then(function() use ($connection) { |
|
353 | 353 | $payload = [ |
354 | 354 | 'socketId' => $connection->socketId, |
355 | 355 | 'appId' => $connection->app->id, |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | return $this->publishClient |
360 | 360 | ->publish($this->getPongRedisHash($connection->app->id), json_encode($payload)); |
361 | 361 | }) |
362 | - ->then(function () use ($connection) { |
|
362 | + ->then(function() use ($connection) { |
|
363 | 363 | return parent::connectionPonged($connection); |
364 | 364 | }); |
365 | 365 | } |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | { |
374 | 374 | $lock = $this->lock(); |
375 | 375 | try { |
376 | - $lock->get(function () { |
|
376 | + $lock->get(function() { |
|
377 | 377 | $this->getConnectionsFromSet(0, now()->subMinutes(2)->format('U')) |
378 | - ->then(function ($connections) { |
|
378 | + ->then(function($connections) { |
|
379 | 379 | foreach ($connections as $socketId => $appId) { |
380 | 380 | $connection = $this->fakeConnectionForApp($appId, $socketId); |
381 | 381 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | |
414 | 414 | $payload->channel = Str::after($redisChannel, "{$payload->appId}:"); |
415 | 415 | |
416 | - if (! $channel = $this->find($payload->appId, $payload->channel)) { |
|
416 | + if (!$channel = $this->find($payload->appId, $payload->channel)) { |
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | public function find($appId, string $channel) |
440 | 440 | { |
441 | - if (! $channelInstance = parent::find($appId, $channel)) { |
|
441 | + if (!$channelInstance = parent::find($appId, $channel)) { |
|
442 | 442 | $class = $this->getChannelClassName($channel); |
443 | 443 | $this->channels[$appId][$channel] = new $class($channel); |
444 | 444 | } |
@@ -581,8 +581,8 @@ discard block |
||
581 | 581 | |
582 | 582 | return $this->publishClient |
583 | 583 | ->zrangebyscore($this->getSocketsRedisHash(), $start, $stop) |
584 | - ->then(function ($list) { |
|
585 | - return collect($list)->mapWithKeys(function ($appWithSocket) { |
|
584 | + ->then(function($list) { |
|
585 | + return collect($list)->mapWithKeys(function($appWithSocket) { |
|
586 | 586 | [$appId, $socketId] = explode(':', $appWithSocket); |
587 | 587 | |
588 | 588 | return [$socketId => $appId]; |