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

Commit 108a717

Browse files
committed
Fixed inconsistency by not passing $appId to all methods
1 parent 714cc5b commit 108a717

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

src/Statistics/Logger/MemoryStatisticsLogger.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver;
77
use BeyondCode\LaravelWebSockets\Statistics\Statistic;
88
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
9-
use Ratchet\ConnectionInterface;
109

1110
class MemoryStatisticsLogger implements StatisticsLogger
1211
{
@@ -47,12 +46,12 @@ public function __construct(ChannelManager $channelManager, StatisticsDriver $dr
4746
/**
4847
* Handle the incoming websocket message.
4948
*
50-
* @param \Ratchet\ConnectionInterface $connection
49+
* @param mixed $appId
5150
* @return void
5251
*/
53-
public function webSocketMessage(ConnectionInterface $connection)
52+
public function webSocketMessage($appId)
5453
{
55-
$this->findOrMakeStatisticForAppId($connection->app->id)
54+
$this->findOrMakeStatisticForAppId($appId)
5655
->webSocketMessage();
5756
}
5857

@@ -71,24 +70,24 @@ public function apiMessage($appId)
7170
/**
7271
* Handle the new conection.
7372
*
74-
* @param \Ratchet\ConnectionInterface $connection
73+
* @param mixed $appId
7574
* @return void
7675
*/
77-
public function connection(ConnectionInterface $connection)
76+
public function connection($appId)
7877
{
79-
$this->findOrMakeStatisticForAppId($connection->app->id)
78+
$this->findOrMakeStatisticForAppId($appId)
8079
->connection();
8180
}
8281

8382
/**
8483
* Handle disconnections.
8584
*
86-
* @param \Ratchet\ConnectionInterface $connection
85+
* @param mixed $appId
8786
* @return void
8887
*/
89-
public function disconnection(ConnectionInterface $connection)
88+
public function disconnection($appId)
9089
{
91-
$this->findOrMakeStatisticForAppId($connection->app->id)
90+
$this->findOrMakeStatisticForAppId($appId)
9291
->disconnection();
9392
}
9493

src/Statistics/Logger/NullStatisticsLogger.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver;
66
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
7-
use Ratchet\ConnectionInterface;
87

98
class NullStatisticsLogger implements StatisticsLogger
109
{
@@ -38,10 +37,10 @@ public function __construct(ChannelManager $channelManager, StatisticsDriver $dr
3837
/**
3938
* Handle the incoming websocket message.
4039
*
41-
* @param \Ratchet\ConnectionInterface $connection
40+
* @param mixed $appId
4241
* @return void
4342
*/
44-
public function webSocketMessage(ConnectionInterface $connection)
43+
public function webSocketMessage($appId)
4544
{
4645
//
4746
}
@@ -60,21 +59,21 @@ public function apiMessage($appId)
6059
/**
6160
* Handle the new conection.
6261
*
63-
* @param \Ratchet\ConnectionInterface $connection
62+
* @param mixed $appId
6463
* @return void
6564
*/
66-
public function connection(ConnectionInterface $connection)
65+
public function connection($appId)
6766
{
6867
//
6968
}
7069

7170
/**
7271
* Handle disconnections.
7372
*
74-
* @param \Ratchet\ConnectionInterface $connection
73+
* @param mixed $appId
7574
* @return void
7675
*/
77-
public function disconnection(ConnectionInterface $connection)
76+
public function disconnection($appId)
7877
{
7978
//
8079
}

src/Statistics/Logger/StatisticsLogger.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
namespace BeyondCode\LaravelWebSockets\Statistics\Logger;
44

5-
use Ratchet\ConnectionInterface;
6-
75
interface StatisticsLogger
86
{
97
/**
108
* Handle the incoming websocket message.
119
*
12-
* @param \Ratchet\ConnectionInterface $connection
10+
* @param mixed $appId
1311
* @return void
1412
*/
15-
public function webSocketMessage(ConnectionInterface $connection);
13+
public function webSocketMessage($appId);
1614

1715
/**
1816
* Handle the incoming API message.
@@ -25,18 +23,18 @@ public function apiMessage($appId);
2523
/**
2624
* Handle the new conection.
2725
*
28-
* @param \Ratchet\ConnectionInterface $connection
26+
* @param mixed $appId
2927
* @return void
3028
*/
31-
public function connection(ConnectionInterface $connection);
29+
public function connection($appId);
3230

3331
/**
3432
* Handle disconnections.
3533
*
36-
* @param \Ratchet\ConnectionInterface $connection
34+
* @param mixed $appId
3735
* @return void
3836
*/
39-
public function disconnection(ConnectionInterface $connection);
37+
public function disconnection($appId);
4038

4139
/**
4240
* Save all the stored statistics.

src/WebSockets/WebSocketHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function onMessage(ConnectionInterface $connection, MessageInterface $mes
6565

6666
$message->respond();
6767

68-
StatisticsLogger::webSocketMessage($connection);
68+
StatisticsLogger::webSocketMessage($connection->app->id);
6969
}
7070

7171
/**
@@ -82,7 +82,7 @@ public function onClose(ConnectionInterface $connection)
8282
'socketId' => $connection->socketId,
8383
]);
8484

85-
StatisticsLogger::disconnection($connection);
85+
StatisticsLogger::disconnection($connection->app->id);
8686
}
8787

8888
/**
@@ -200,7 +200,7 @@ protected function establishConnection(ConnectionInterface $connection)
200200
'socketId' => $connection->socketId,
201201
]);
202202

203-
StatisticsLogger::connection($connection);
203+
StatisticsLogger::connection($connection->app->id);
204204

205205
return $this;
206206
}

0 commit comments

Comments
 (0)