diff --git a/src/Statistics/Logger/MemoryStatisticsLogger.php b/src/Statistics/Logger/MemoryStatisticsLogger.php index fe0ac82..43c9db4 100644 --- a/src/Statistics/Logger/MemoryStatisticsLogger.php +++ b/src/Statistics/Logger/MemoryStatisticsLogger.php @@ -6,7 +6,6 @@ use BeyondCode\LaravelWebSockets\Apps\App; use BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver; use BeyondCode\LaravelWebSockets\Statistics\Statistic; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; -use Ratchet\ConnectionInterface; class MemoryStatisticsLogger implements StatisticsLogger { @@ -47,12 +46,12 @@ class MemoryStatisticsLogger implements StatisticsLogger /** * Handle the incoming websocket message. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function webSocketMessage(ConnectionInterface $connection) + public function webSocketMessage($appId) { - $this->findOrMakeStatisticForAppId($connection->app->id) + $this->findOrMakeStatisticForAppId($appId) ->webSocketMessage(); } @@ -71,24 +70,24 @@ class MemoryStatisticsLogger implements StatisticsLogger /** * Handle the new conection. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function connection(ConnectionInterface $connection) + public function connection($appId) { - $this->findOrMakeStatisticForAppId($connection->app->id) + $this->findOrMakeStatisticForAppId($appId) ->connection(); } /** * Handle disconnections. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function disconnection(ConnectionInterface $connection) + public function disconnection($appId) { - $this->findOrMakeStatisticForAppId($connection->app->id) + $this->findOrMakeStatisticForAppId($appId) ->disconnection(); } diff --git a/src/Statistics/Logger/NullStatisticsLogger.php b/src/Statistics/Logger/NullStatisticsLogger.php index 94e3547..1120c2e 100644 --- a/src/Statistics/Logger/NullStatisticsLogger.php +++ b/src/Statistics/Logger/NullStatisticsLogger.php @@ -4,7 +4,6 @@ namespace BeyondCode\LaravelWebSockets\Statistics\Logger; use BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver; use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager; -use Ratchet\ConnectionInterface; class NullStatisticsLogger implements StatisticsLogger { @@ -38,10 +37,10 @@ class NullStatisticsLogger implements StatisticsLogger /** * Handle the incoming websocket message. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function webSocketMessage(ConnectionInterface $connection) + public function webSocketMessage($appId) { // } @@ -60,10 +59,10 @@ class NullStatisticsLogger implements StatisticsLogger /** * Handle the new conection. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function connection(ConnectionInterface $connection) + public function connection($appId) { // } @@ -71,10 +70,10 @@ class NullStatisticsLogger implements StatisticsLogger /** * Handle disconnections. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function disconnection(ConnectionInterface $connection) + public function disconnection($appId) { // } diff --git a/src/Statistics/Logger/StatisticsLogger.php b/src/Statistics/Logger/StatisticsLogger.php index 84b09db..6f6fe0c 100644 --- a/src/Statistics/Logger/StatisticsLogger.php +++ b/src/Statistics/Logger/StatisticsLogger.php @@ -2,17 +2,15 @@ namespace BeyondCode\LaravelWebSockets\Statistics\Logger; -use Ratchet\ConnectionInterface; - interface StatisticsLogger { /** * Handle the incoming websocket message. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function webSocketMessage(ConnectionInterface $connection); + public function webSocketMessage($appId); /** * Handle the incoming API message. @@ -25,18 +23,18 @@ interface StatisticsLogger /** * Handle the new conection. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function connection(ConnectionInterface $connection); + public function connection($appId); /** * Handle disconnections. * - * @param \Ratchet\ConnectionInterface $connection + * @param mixed $appId * @return void */ - public function disconnection(ConnectionInterface $connection); + public function disconnection($appId); /** * Save all the stored statistics. diff --git a/src/WebSockets/WebSocketHandler.php b/src/WebSockets/WebSocketHandler.php index 7a2537e..0f00342 100644 --- a/src/WebSockets/WebSocketHandler.php +++ b/src/WebSockets/WebSocketHandler.php @@ -65,7 +65,7 @@ class WebSocketHandler implements MessageComponentInterface $message->respond(); - StatisticsLogger::webSocketMessage($connection); + StatisticsLogger::webSocketMessage($connection->app->id); } /** @@ -82,7 +82,7 @@ class WebSocketHandler implements MessageComponentInterface 'socketId' => $connection->socketId, ]); - StatisticsLogger::disconnection($connection); + StatisticsLogger::disconnection($connection->app->id); } /** @@ -200,7 +200,7 @@ class WebSocketHandler implements MessageComponentInterface 'socketId' => $connection->socketId, ]); - StatisticsLogger::connection($connection); + StatisticsLogger::connection($connection->app->id); return $this; }