rename
This commit is contained in:
parent
5a03b981b9
commit
9636f7de6b
|
|
@ -28,7 +28,7 @@ class TriggerEventController extends Controller
|
||||||
$request->json()->get('data')
|
$request->json()->get('data')
|
||||||
);
|
);
|
||||||
|
|
||||||
StatisticsLogger::logApiMessage($request->appId);
|
StatisticsLogger::apiMessage($request->appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $request->json()->all();
|
return $request->json()->all();
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,22 @@ use Ratchet\ConnectionInterface;
|
||||||
class FakeStatisticsLogger implements StatisticsLogger
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,32 +23,32 @@ class HttpStatisticsLogger implements StatisticsLogger
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logWebSocketMessage(ConnectionInterface $connection)
|
public function webSocketMessage(ConnectionInterface $connection)
|
||||||
{
|
{
|
||||||
$this->initializeStatistics($connection->app->id);
|
$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->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->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->initializeStatistics($connection->app->id);
|
||||||
|
|
||||||
$this->statistics[$connection->app->id]->logDisconnection();
|
$this->statistics[$connection->app->id]->disconnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function initializeStatistics($id)
|
protected function initializeStatistics($id)
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
namespace BeyondCode\LaravelWebSockets\Statistics\Logger;
|
namespace BeyondCode\LaravelWebSockets\Statistics\Logger;
|
||||||
|
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\connectionInterface;
|
||||||
|
|
||||||
interface StatisticsLogger
|
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();
|
public function save();
|
||||||
}
|
}
|
||||||
|
|
@ -31,26 +31,26 @@ class Statistic
|
||||||
return App::findById($this->appId)->statisticsEnabled;
|
return App::findById($this->appId)->statisticsEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logConnection()
|
public function connection()
|
||||||
{
|
{
|
||||||
$this->currentConnectionCount++;
|
$this->currentConnectionCount++;
|
||||||
|
|
||||||
$this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount);
|
$this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logDisconnection()
|
public function disconnection()
|
||||||
{
|
{
|
||||||
$this->currentConnectionCount--;
|
$this->currentConnectionCount--;
|
||||||
|
|
||||||
$this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount);
|
$this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logWebSocketMessage()
|
public function webSocketMessage()
|
||||||
{
|
{
|
||||||
$this->webSocketMessageCount++;
|
$this->webSocketMessageCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logApiMessage()
|
public function apiMessage()
|
||||||
{
|
{
|
||||||
$this->apiMessageCount++;
|
$this->apiMessageCount++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class WebSocketHandler implements MessageComponentInterface
|
||||||
|
|
||||||
$message->respond();
|
$message->respond();
|
||||||
|
|
||||||
StatisticsLogger::logWebSocketMessage($connection);
|
StatisticsLogger::webSocketMessage($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onClose(ConnectionInterface $connection)
|
public function onClose(ConnectionInterface $connection)
|
||||||
|
|
@ -48,7 +48,7 @@ class WebSocketHandler implements MessageComponentInterface
|
||||||
|
|
||||||
DashboardLogger::disconnection($connection);
|
DashboardLogger::disconnection($connection);
|
||||||
|
|
||||||
StatisticsLogger::logDisconnection($connection);
|
StatisticsLogger::disconnection($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onError(ConnectionInterface $connection, Exception $exception)
|
public function onError(ConnectionInterface $connection, Exception $exception)
|
||||||
|
|
@ -94,7 +94,7 @@ class WebSocketHandler implements MessageComponentInterface
|
||||||
|
|
||||||
DashboardLogger::connection($connection);
|
DashboardLogger::connection($connection);
|
||||||
|
|
||||||
StatisticsLogger::logConnection($connection);
|
StatisticsLogger::connection($connection);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue