Fixed inconsistency by not passing $appId to all methods
This commit is contained in:
parent
714cc5b22d
commit
108a717c0a
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue