Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 09776a1

Browse files
committed
Refactored the statistics logger
1 parent 5890659 commit 09776a1

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

config/websockets.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,13 @@
191191
| store them into an array and then store them into the database
192192
| on each interval.
193193
|
194+
| You can opt-in to avoid any statistics storage by setting the logger
195+
| to the built-in NullLogger.
196+
|
194197
*/
195198

196-
'logger' => BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class,
199+
'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class,
200+
// 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\NullStatisticsLogger::class,
197201

198202
/*
199203
|--------------------------------------------------------------------------

src/Facades/StatisticsLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Support\Facades\Facade;
77

88
/**
9-
* @see \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger
9+
* @see \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger
1010
* @mixin \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger
1111
*/
1212
class StatisticsLogger extends Facade
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace BeyondCode\LaravelWebSockets\Statistics\Logger;
4+
5+
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
6+
use Clue\React\Buzz\Browser;
7+
use Ratchet\ConnectionInterface;
8+
9+
class NullStatisticsLogger implements StatisticsLogger
10+
{
11+
/** @var \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager */
12+
protected $channelManager;
13+
14+
/** @var \Clue\React\Buzz\Browser */
15+
protected $browser;
16+
17+
public function __construct(ChannelManager $channelManager, Browser $browser)
18+
{
19+
$this->channelManager = $channelManager;
20+
$this->browser = $browser;
21+
}
22+
23+
public function webSocketMessage(ConnectionInterface $connection)
24+
{
25+
//
26+
}
27+
28+
public function apiMessage($appId)
29+
{
30+
//
31+
}
32+
33+
public function connection(ConnectionInterface $connection)
34+
{
35+
//
36+
}
37+
38+
public function disconnection(ConnectionInterface $connection)
39+
{
40+
//
41+
}
42+
43+
public function save()
44+
{
45+
//
46+
}
47+
}

0 commit comments

Comments
 (0)