@@ -35,7 +35,7 @@ |
||
| 35 | 35 | { |
| 36 | 36 | $this->channelManager |
| 37 | 37 | ->connectionPonged($connection) |
| 38 | - ->then(function () use ($connection) { |
|
| 38 | + ->then(function() use ($connection) { |
|
| 39 | 39 | $connection->send(json_encode(['event' => 'pusher:pong'])); |
| 40 | 40 | |
| 41 | 41 | ConnectionPonged::dispatch($connection->app->id, $connection->socketId); |
@@ -175,7 +175,7 @@ |
||
| 175 | 175 | public function registerCustomRoutes() |
| 176 | 176 | { |
| 177 | 177 | foreach ($this->customRoutes as $method => $actions) { |
| 178 | - $actions->each(function ($action, $uri) use ($method) { |
|
| 178 | + $actions->each(function($action, $uri) use ($method) { |
|
| 179 | 179 | $this->{$method}($uri, $action); |
| 180 | 180 | }); |
| 181 | 181 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | */ |
| 97 | 97 | protected function warn(string $message) |
| 98 | 98 | { |
| 99 | - if (! $this->consoleOutput->getFormatter()->hasStyle('warning')) { |
|
| 99 | + if (!$this->consoleOutput->getFormatter()->hasStyle('warning')) { |
|
| 100 | 100 | $style = new OutputFormatterStyle('yellow'); |
| 101 | 101 | |
| 102 | 102 | $this->consoleOutput->getFormatter()->setStyle('warning', $style); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function onOpen(ConnectionInterface $connection) |
| 44 | 44 | { |
| 45 | - if (! $this->connectionCanBeMade($connection)) { |
|
| 45 | + if (!$this->connectionCanBeMade($connection)) { |
|
| 46 | 46 | return $connection->close(); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function onMessage(ConnectionInterface $connection, MessageInterface $message) |
| 84 | 84 | { |
| 85 | - if (! isset($connection->app)) { |
|
| 85 | + if (!isset($connection->app)) { |
|
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $this->channelManager |
| 113 | 113 | ->unsubscribeFromAllChannels($connection) |
| 114 | - ->then(function (bool $unsubscribed) use ($connection) { |
|
| 114 | + ->then(function(bool $unsubscribed) use ($connection) { |
|
| 115 | 115 | if (isset($connection->app)) { |
| 116 | 116 | if ($connection->app->statisticsEnabled) { |
| 117 | 117 | StatisticsCollector::disconnection($connection->app->id); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $appKey = $query->get('appKey'); |
| 170 | 170 | |
| 171 | - if (! $app = App::findByKey($appKey)) { |
|
| 171 | + if (!$app = App::findByKey($appKey)) { |
|
| 172 | 172 | throw new Exceptions\UnknownAppKey($appKey); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | protected function verifyOrigin(ConnectionInterface $connection) |
| 187 | 187 | { |
| 188 | - if (! $connection->app->allowedOrigins) { |
|
| 188 | + if (!$connection->app->allowedOrigins) { |
|
| 189 | 189 | return $this; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | $origin = parse_url($header, PHP_URL_HOST) ?: $header; |
| 195 | 195 | |
| 196 | - if (! $header || ! in_array($origin, $connection->app->allowedOrigins)) { |
|
| 196 | + if (!$header || !in_array($origin, $connection->app->allowedOrigins)) { |
|
| 197 | 197 | throw new Exceptions\OriginNotAllowed($connection->app->key); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -208,10 +208,10 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | protected function limitConcurrentConnections(ConnectionInterface $connection) |
| 210 | 210 | { |
| 211 | - if (! is_null($capacity = $connection->app->capacity)) { |
|
| 211 | + if (!is_null($capacity = $connection->app->capacity)) { |
|
| 212 | 212 | $this->channelManager |
| 213 | 213 | ->getGlobalConnectionsCount($connection->app->id) |
| 214 | - ->then(function ($connectionsCount) use ($capacity, $connection) { |
|
| 214 | + ->then(function($connectionsCount) use ($capacity, $connection) { |
|
| 215 | 215 | if ($connectionsCount >= $capacity) { |
| 216 | 216 | $exception = new Exceptions\ConnectionsOverCapacity; |
| 217 | 217 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function all(): array |
| 32 | 32 | { |
| 33 | 33 | return $this->apps |
| 34 | - ->map(function (array $appAttributes) { |
|
| 34 | + ->map(function(array $appAttributes) { |
|
| 35 | 35 | return $this->convertIntoApp($appAttributes); |
| 36 | 36 | }) |
| 37 | 37 | ->toArray(); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function convertIntoApp(?array $appAttributes): ?App |
| 86 | 86 | { |
| 87 | - if (! $appAttributes) { |
|
| 87 | + if (!$appAttributes) { |
|
| 88 | 88 | return null; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function __invoke(Request $request, $appId) |
| 18 | 18 | { |
| 19 | - $processQuery = function ($query) use ($appId) { |
|
| 19 | + $processQuery = function($query) use ($appId) { |
|
| 20 | 20 | return $query->whereAppId($appId) |
| 21 | 21 | ->latest() |
| 22 | 22 | ->limit(120); |
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | - $processCollection = function ($collection) { |
|
| 25 | + $processCollection = function($collection) { |
|
| 26 | 26 | return $collection->reverse(); |
| 27 | 27 | }; |
| 28 | 28 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function unsubscribe(ConnectionInterface $connection): bool |
| 122 | 122 | { |
| 123 | - if (! $this->hasConnection($connection)) { |
|
| 123 | + if (!$this->hasConnection($connection)) { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | public function broadcast($appId, stdClass $payload, bool $replicate = true): bool |
| 169 | 169 | { |
| 170 | 170 | collect($this->getConnections()) |
| 171 | - ->each(function ($connection) use ($payload) { |
|
| 171 | + ->each(function($connection) use ($payload) { |
|
| 172 | 172 | $connection->send(json_encode($payload)); |
| 173 | 173 | $this->channelManager->connectionPonged($connection); |
| 174 | 174 | }); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | return $this->broadcast($appId, $payload, false); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - collect($this->getConnections())->each(function (ConnectionInterface $connection) use ($socketId, $payload) { |
|
| 214 | + collect($this->getConnections())->each(function(ConnectionInterface $connection) use ($socketId, $payload) { |
|
| 215 | 215 | if ($connection->socketId !== $socketId) { |
| 216 | 216 | $connection->send(json_encode($payload)); |
| 217 | 217 | $this->channelManager->connectionPonged($connection); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $signature .= ":{$payload->channel_data}"; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if (! hash_equals( |
|
| 256 | + if (!hash_equals( |
|
| 257 | 257 | hash_hmac('sha256', $signature, $connection->app->secret), |
| 258 | 258 | Str::after($payload->auth, ':')) |
| 259 | 259 | ) { |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $this->channelManager |
| 34 | 34 | ->userJoinedPresenceChannel($connection, $user, $this->getName(), $payload) |
| 35 | - ->then(function () use ($connection) { |
|
| 35 | + ->then(function() use ($connection) { |
|
| 36 | 36 | $this->channelManager |
| 37 | 37 | ->getChannelMembers($connection->app->id, $this->getName()) |
| 38 | - ->then(function ($users) use ($connection) { |
|
| 38 | + ->then(function($users) use ($connection) { |
|
| 39 | 39 | $hash = []; |
| 40 | 40 | |
| 41 | 41 | foreach ($users as $socketId => $user) { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | 'channel' => $this->getName(), |
| 48 | 48 | 'data' => json_encode([ |
| 49 | 49 | 'presence' => [ |
| 50 | - 'ids' => collect($users)->map(function ($user) { |
|
| 50 | + 'ids' => collect($users)->map(function($user) { |
|
| 51 | 51 | return (string) $user->user_id; |
| 52 | 52 | })->values(), |
| 53 | 53 | 'hash' => $hash, |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | ])); |
| 58 | 58 | }); |
| 59 | 59 | }) |
| 60 | - ->then(function () use ($connection, $user, $payload) { |
|
| 60 | + ->then(function() use ($connection, $user, $payload) { |
|
| 61 | 61 | // The `pusher_internal:member_added` event is triggered when a user joins a channel. |
| 62 | 62 | // It's quite possible that a user can have multiple connections to the same channel |
| 63 | 63 | // (for example by having multiple browser tabs open) |
| 64 | 64 | // and in this case the events will only be triggered when the first tab is opened. |
| 65 | 65 | $this->channelManager |
| 66 | 66 | ->getMemberSockets($user->user_id, $connection->app->id, $this->getName()) |
| 67 | - ->then(function ($sockets) use ($payload, $connection, $user) { |
|
| 67 | + ->then(function($sockets) use ($payload, $connection, $user) { |
|
| 68 | 68 | if (count($sockets) === 1) { |
| 69 | 69 | $memberAddedPayload = [ |
| 70 | 70 | 'event' => 'pusher_internal:member_added', |
@@ -108,24 +108,24 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $this->channelManager |
| 110 | 110 | ->getChannelMember($connection, $this->getName()) |
| 111 | - ->then(function ($user) { |
|
| 111 | + ->then(function($user) { |
|
| 112 | 112 | return @json_decode($user); |
| 113 | 113 | }) |
| 114 | - ->then(function ($user) use ($connection) { |
|
| 115 | - if (! $user) { |
|
| 114 | + ->then(function($user) use ($connection) { |
|
| 115 | + if (!$user) { |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $this->channelManager |
| 120 | 120 | ->userLeftPresenceChannel($connection, $user, $this->getName()) |
| 121 | - ->then(function () use ($connection, $user) { |
|
| 121 | + ->then(function() use ($connection, $user) { |
|
| 122 | 122 | // The `pusher_internal:member_removed` is triggered when a user leaves a channel. |
| 123 | 123 | // It's quite possible that a user can have multiple connections to the same channel |
| 124 | 124 | // (for example by having multiple browser tabs open) |
| 125 | 125 | // and in this case the events will only be triggered when the last one is closed. |
| 126 | 126 | $this->channelManager |
| 127 | 127 | ->getMemberSockets($user->user_id, $connection->app->id, $this->getName()) |
| 128 | - ->then(function ($sockets) use ($connection, $user) { |
|
| 128 | + ->then(function($sockets) use ($connection, $user) { |
|
| 129 | 129 | if (count($sockets) === 0) { |
| 130 | 130 | $memberRemovedPayload = [ |
| 131 | 131 | 'event' => 'pusher_internal:member_removed', |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::table('websockets_statistics_entries', function (Blueprint $table) { |
|
| 16 | + Schema::table('websockets_statistics_entries', function(Blueprint $table) { |
|
| 17 | 17 | $table->renameColumn('peak_connection_count', 'peak_connections_count'); |
| 18 | 18 | }); |
| 19 | - Schema::table('websockets_statistics_entries', function (Blueprint $table) { |
|
| 19 | + Schema::table('websockets_statistics_entries', function(Blueprint $table) { |
|
| 20 | 20 | $table->renameColumn('websocket_message_count', 'websocket_messages_count'); |
| 21 | 21 | }); |
| 22 | - Schema::table('websockets_statistics_entries', function (Blueprint $table) { |
|
| 22 | + Schema::table('websockets_statistics_entries', function(Blueprint $table) { |
|
| 23 | 23 | $table->renameColumn('api_message_count', 'api_messages_count'); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function down() |
| 33 | 33 | { |
| 34 | - Schema::table('websockets_statistics_entries', function (Blueprint $table) { |
|
| 34 | + Schema::table('websockets_statistics_entries', function(Blueprint $table) { |
|
| 35 | 35 | $table->renameColumn('peak_connections_count', 'peak_connection_count'); |
| 36 | 36 | }); |
| 37 | - Schema::table('websockets_statistics_entries', function (Blueprint $table) { |
|
| 37 | + Schema::table('websockets_statistics_entries', function(Blueprint $table) { |
|
| 38 | 38 | $table->renameColumn('websocket_messages_count', 'websocket_message_count'); |
| 39 | 39 | }); |
| 40 | - Schema::table('websockets_statistics_entries', function (Blueprint $table) { |
|
| 40 | + Schema::table('websockets_statistics_entries', function(Blueprint $table) { |
|
| 41 | 41 | $table->renameColumn('api_messages_count', 'api_message_count'); |
| 42 | 42 | }); |
| 43 | 43 | } |