nitpicks
This commit is contained in:
parent
9fde33d683
commit
3a0ba1d594
|
|
@ -9,19 +9,12 @@ use stdClass;
|
|||
class Dashboard
|
||||
{
|
||||
const LOG_CHANNEL_PREFIX = 'private-websockets-dashboard-';
|
||||
|
||||
const TYPE_DISCONNECTION = 'disconnection';
|
||||
|
||||
const TYPE_CONNECTION = 'connection';
|
||||
|
||||
const TYPE_VACATED = 'vacated';
|
||||
|
||||
const TYPE_OCCUPIED = 'occupied';
|
||||
|
||||
const TYPE_SUBSCRIBED = 'subscribed';
|
||||
|
||||
const TYPE_CLIENT_MESSAGE = 'client_message';
|
||||
|
||||
const TYPE_API_MESSAGE = 'api_message';
|
||||
|
||||
public static function connection(ConnectionInterface $connection)
|
||||
|
|
@ -29,61 +22,61 @@ class Dashboard
|
|||
/** @var \GuzzleHttp\Psr7\Request $request */
|
||||
$request = $connection->httpRequest;
|
||||
|
||||
self::log($connection->client->appId, self::TYPE_CONNECTION, [
|
||||
static::log($connection->client->appId, static::TYPE_CONNECTION, [
|
||||
'details' => "Origin: {$request->getUri()->getScheme()}://{$request->getUri()->getHost()}",
|
||||
'socketId' => $connection->socketId,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function disconnection(ConnectionInterface $connection)
|
||||
{
|
||||
self::log($connection->client->appId, self::TYPE_DISCONNECTION, [
|
||||
'socketId' => $connection->socketId
|
||||
]);
|
||||
}
|
||||
|
||||
public static function vacated(ConnectionInterface $connection, string $channelId)
|
||||
{
|
||||
self::log($connection->client->appId, self::TYPE_VACATED, [
|
||||
'details' => "Channel: {$channelId}"
|
||||
]);
|
||||
}
|
||||
|
||||
public static function occupied(ConnectionInterface $connection, string $channelId)
|
||||
{
|
||||
self::log($connection->client->appId, self::TYPE_OCCUPIED, [
|
||||
'details' => "Channel: {$channelId}"
|
||||
static::log($connection->client->appId, static::TYPE_OCCUPIED, [
|
||||
'details' => "Channel: {$channelId}",
|
||||
]);
|
||||
}
|
||||
|
||||
public static function subscribed(ConnectionInterface $connection, string $channelId)
|
||||
{
|
||||
self::log($connection->client->appId, self::TYPE_SUBSCRIBED, [
|
||||
static::log($connection->client->appId, static::TYPE_SUBSCRIBED, [
|
||||
'socketId' => $connection->socketId,
|
||||
'details' => "Channel: {$channelId}"
|
||||
'details' => "Channel: {$channelId}",
|
||||
]);
|
||||
}
|
||||
|
||||
public static function clientMessage(ConnectionInterface $connection, stdClass $payload)
|
||||
{
|
||||
self::log($connection->client->appId, self::TYPE_CLIENT_MESSAGE, [
|
||||
static::log($connection->client->appId, static::TYPE_CLIENT_MESSAGE, [
|
||||
'details' => "Channel: {$payload->channel}, Event: {$payload->event}",
|
||||
'socketId' => $connection->socketId,
|
||||
'data' => json_encode($payload)
|
||||
'data' => json_encode($payload),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function disconnection(ConnectionInterface $connection)
|
||||
{
|
||||
static::log($connection->client->appId, static::TYPE_DISCONNECTION, [
|
||||
'socketId' => $connection->socketId,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function vacated(ConnectionInterface $connection, string $channelId)
|
||||
{
|
||||
static::log($connection->client->appId, static::TYPE_VACATED, [
|
||||
'details' => "Channel: {$channelId}",
|
||||
]);
|
||||
}
|
||||
|
||||
public static function apiMessage($appId, string $channel, string $event, string $payload)
|
||||
{
|
||||
self::log($appId, self::TYPE_API_MESSAGE, [
|
||||
static::log($appId, static::TYPE_API_MESSAGE, [
|
||||
'details' => "Channel: {$channel}, Event: {$event}",
|
||||
'data' => $payload
|
||||
'data' => $payload,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function log($appId, string $type, array $attributes = [])
|
||||
{
|
||||
$channelId = self::LOG_CHANNEL_PREFIX . $type;
|
||||
$channelId = static::LOG_CHANNEL_PREFIX . $type;
|
||||
|
||||
$channel = app(ChannelManager::class)->find($appId, $channelId);
|
||||
|
||||
|
|
@ -93,7 +86,7 @@ class Dashboard
|
|||
'data' => [
|
||||
'type' => $type,
|
||||
'time' => strftime("%H:%M:%S")
|
||||
] + $attributes
|
||||
] + $attributes,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class InvalidConnectionException extends PusherException
|
|||
public function __construct()
|
||||
{
|
||||
$this->message = 'Invalid Connection';
|
||||
|
||||
$this->code = 4009;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ class InvalidSignatureException extends PusherException
|
|||
public function __construct()
|
||||
{
|
||||
$this->message = 'Invalid Signature';
|
||||
|
||||
$this->code = 4009;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@ class WebSocketController implements MessageComponentInterface
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
function onClose(ConnectionInterface $connection)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue