This commit is contained in:
freek 2018-12-03 16:23:20 +01:00
parent 5a03b981b9
commit 9636f7de6b
6 changed files with 25 additions and 25 deletions

View File

@ -28,7 +28,7 @@ class TriggerEventController extends Controller
$request->json()->get('data')
);
StatisticsLogger::logApiMessage($request->appId);
StatisticsLogger::apiMessage($request->appId);
}
return $request->json()->all();

View File

@ -10,22 +10,22 @@ use Ratchet\ConnectionInterface;
class FakeStatisticsLogger implements StatisticsLogger
{
public function logWebSocketMessage(ConnectionInterface $connection)
public function webSocketMessage(ConnectionInterface $connection)
{
}
public function logApiMessage($appId)
public function apiMessage($appId)
{
}
public function logConnection(ConnectionInterface $connection)
public function connection(ConnectionInterface $connection)
{
}
public function logDisconnection(ConnectionInterface $connection)
public function disconnection(ConnectionInterface $connection)
{
}

View File

@ -23,32 +23,32 @@ class HttpStatisticsLogger implements StatisticsLogger
$this->client = $client;
}
public function logWebSocketMessage(ConnectionInterface $connection)
public function webSocketMessage(ConnectionInterface $connection)
{
$this->initializeStatistics($connection->app->id);
$this->statistics[$connection->app->id]->logWebSocketMessage();
$this->statistics[$connection->app->id]->webSocketMessage();
}
public function logApiMessage($appId)
public function apiMessage($appId)
{
$this->initializeStatistics($appId);
$this->statistics[$appId]->logApiMessage();
$this->statistics[$appId]->apiMessage();
}
public function logConnection(ConnectionInterface $connection)
public function connection(ConnectionInterface $connection)
{
$this->initializeStatistics($connection->app->id);
$this->statistics[$connection->app->id]->logConnection();
$this->statistics[$connection->app->id]->connection();
}
public function logDisconnection(ConnectionInterface $connection)
public function disconnection(ConnectionInterface $connection)
{
$this->initializeStatistics($connection->app->id);
$this->statistics[$connection->app->id]->logDisconnection();
$this->statistics[$connection->app->id]->disconnection();
}
protected function initializeStatistics($id)

View File

@ -2,17 +2,17 @@
namespace BeyondCode\LaravelWebSockets\Statistics\Logger;
use Ratchet\ConnectionInterface;
use Ratchet\connectionInterface;
interface StatisticsLogger
{
public function logWebSocketMessage(ConnectionInterface $connection);
public function webSocketMessage(connectionInterface $connection);
public function logApiMessage($appId);
public function apiMessage($appId);
public function logConnection(ConnectionInterface $connection);
public function connection(connectionInterface $connection);
public function logDisconnection(ConnectionInterface $connection);
public function disconnection(connectionInterface $connection);
public function save();
}

View File

@ -31,26 +31,26 @@ class Statistic
return App::findById($this->appId)->statisticsEnabled;
}
public function logConnection()
public function connection()
{
$this->currentConnectionCount++;
$this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount);
}
public function logDisconnection()
public function disconnection()
{
$this->currentConnectionCount--;
$this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount);
}
public function logWebSocketMessage()
public function webSocketMessage()
{
$this->webSocketMessageCount++;
}
public function logApiMessage()
public function apiMessage()
{
$this->apiMessageCount++;
}

View File

@ -39,7 +39,7 @@ class WebSocketHandler implements MessageComponentInterface
$message->respond();
StatisticsLogger::logWebSocketMessage($connection);
StatisticsLogger::webSocketMessage($connection);
}
public function onClose(ConnectionInterface $connection)
@ -48,7 +48,7 @@ class WebSocketHandler implements MessageComponentInterface
DashboardLogger::disconnection($connection);
StatisticsLogger::logDisconnection($connection);
StatisticsLogger::disconnection($connection);
}
public function onError(ConnectionInterface $connection, Exception $exception)
@ -94,7 +94,7 @@ class WebSocketHandler implements MessageComponentInterface
DashboardLogger::connection($connection);
StatisticsLogger::logConnection($connection);
StatisticsLogger::connection($connection);
return $this;
}