diff --git a/src/Console/StartWebSocketServer.php b/src/Console/StartWebSocketServer.php index f92039c..d00e69f 100644 --- a/src/Console/StartWebSocketServer.php +++ b/src/Console/StartWebSocketServer.php @@ -9,12 +9,12 @@ use React\Dns\Config\Config as DnsConfig; use React\Dns\Resolver\ResolverInterface; use React\EventLoop\Factory as LoopFactory; use React\Dns\Resolver\Factory as DnsFactory; -use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; use BeyondCode\LaravelWebSockets\Statistics\DnsResolver; use BeyondCode\LaravelWebSockets\Facades\StatisticsLogger; use BeyondCode\LaravelWebSockets\Facades\WebSocketsRouter; use BeyondCode\LaravelWebSockets\PubSub\Redis\RedisClient; use BeyondCode\LaravelWebSockets\Server\Logger\HttpLogger; +use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; use BeyondCode\LaravelWebSockets\Server\WebSocketServerFactory; use BeyondCode\LaravelWebSockets\Server\Logger\ConnectionLogger; use BeyondCode\LaravelWebSockets\Server\Logger\WebsocketsLogger; diff --git a/src/PubSub/Redis/RedisClient.php b/src/PubSub/Redis/RedisClient.php index a393ac1..6634ecd 100644 --- a/src/PubSub/Redis/RedisClient.php +++ b/src/PubSub/Redis/RedisClient.php @@ -51,7 +51,7 @@ class RedisClient implements ReplicationInterface } /** - * Boot the RedisClient, initializing the connections + * Boot the RedisClient, initializing the connections. * * @param LoopInterface $loop * @return ReplicationInterface @@ -74,7 +74,7 @@ class RedisClient implements ReplicationInterface } /** - * Handle a message received from Redis on a specific channel + * Handle a message received from Redis on a specific channel. * * @param string $redisChannel * @param string $payload @@ -115,7 +115,7 @@ class RedisClient implements ReplicationInterface } /** - * Subscribe to a channel on behalf of websocket user + * Subscribe to a channel on behalf of websocket user. * * @param string $appId * @param string $channel @@ -136,7 +136,7 @@ class RedisClient implements ReplicationInterface } /** - * Unsubscribe from a channel on behalf of a websocket user + * Unsubscribe from a channel on behalf of a websocket user. * * @param string $appId * @param string $channel @@ -161,7 +161,7 @@ class RedisClient implements ReplicationInterface } /** - * Publish a message to a channel on behalf of a websocket user + * Publish a message to a channel on behalf of a websocket user. * * @param string $appId * @param string $channel @@ -179,7 +179,7 @@ class RedisClient implements ReplicationInterface } /** - * Build the Redis connection URL from Laravel database config + * Build the Redis connection URL from Laravel database config. * * @return string */ @@ -188,7 +188,7 @@ class RedisClient implements ReplicationInterface $name = config('websockets.replication.connection') ?? 'default'; $config = config("database.redis.$name"); $host = $config['host']; - $port = $config['port'] ? (':' . $config['port']) : ':6379'; + $port = $config['port'] ? (':'.$config['port']) : ':6379'; $query = []; if ($config['password']) { diff --git a/src/PubSub/ReplicationInterface.php b/src/PubSub/ReplicationInterface.php index f1049c4..5131ea3 100644 --- a/src/PubSub/ReplicationInterface.php +++ b/src/PubSub/ReplicationInterface.php @@ -8,7 +8,7 @@ use React\EventLoop\LoopInterface; interface ReplicationInterface { /** - * Boot the pub/sub provider (open connections, initial subscriptions, etc.) + * Boot the pub/sub provider (open connections, initial subscriptions, etc). * * @param LoopInterface $loop * @return self @@ -16,7 +16,7 @@ interface ReplicationInterface public function boot(LoopInterface $loop): self; /** - * Publish a payload on a specific channel, for a specific app + * Publish a payload on a specific channel, for a specific app. * * @param string $appId * @param string $channel @@ -26,7 +26,7 @@ interface ReplicationInterface public function publish(string $appId, string $channel, stdClass $payload): bool; /** - * Subscribe to receive messages for a channel + * Subscribe to receive messages for a channel. * * @param string $channel * @return bool @@ -34,7 +34,7 @@ interface ReplicationInterface public function subscribe(string $appId, string $channel): bool; /** - * Unsubscribe from a channel + * Unsubscribe from a channel. * * @param string $channel * @return bool diff --git a/src/WebSockets/Channels/Channel.php b/src/WebSockets/Channels/Channel.php index b033b48..605a7db 100644 --- a/src/WebSockets/Channels/Channel.php +++ b/src/WebSockets/Channels/Channel.php @@ -5,8 +5,8 @@ namespace BeyondCode\LaravelWebSockets\WebSockets\Channels; use stdClass; use Illuminate\Support\Str; use Ratchet\ConnectionInterface; -use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger; +use BeyondCode\LaravelWebSockets\PubSub\ReplicationInterface; use BeyondCode\LaravelWebSockets\WebSockets\Exceptions\InvalidSignature; class Channel @@ -114,6 +114,7 @@ class Channel { if (is_null($socketId)) { $this->broadcast($payload); + return; } diff --git a/src/WebSocketsServiceProvider.php b/src/WebSocketsServiceProvider.php index 9057a48..558c8ef 100644 --- a/src/WebSocketsServiceProvider.php +++ b/src/WebSocketsServiceProvider.php @@ -46,7 +46,7 @@ class WebSocketsServiceProvider extends ServiceProvider Console\CleanStatistics::class, ]); - $broadcastManager->extend('redis-pusher', function(array $config) { + $broadcastManager->extend('redis-pusher', function (array $config) { $pusher = new Pusher( $config['key'], $config['secret'], $config['app_id'], $config['options'] ?? []