This repository was archived by the owner on Feb 7, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function disconnection(ConnectionInterface $connection)
57
57
58
58
protected function findOrMakeStatisticForAppId ($ appId ): Statistic
59
59
{
60
- if (! isset ($ this ->statistics [$ appId ])) {
60
+ if (!isset ($ this ->statistics [$ appId ])) {
61
61
$ this ->statistics [$ appId ] = new Statistic ($ appId );
62
62
}
63
63
@@ -68,23 +68,19 @@ public function save()
68
68
{
69
69
foreach ($ this ->statistics as $ appId => $ statistic ) {
70
70
71
- if (! $ statistic ->isEnabled ()) {
71
+ if (!$ statistic ->isEnabled ()) {
72
72
continue ;
73
73
}
74
74
75
- $ this ->browser
75
+ $ this
76
+ ->browser
76
77
->post (
77
78
action ([WebSocketStatisticsEntriesController::class, 'store ' ]),
78
79
['Content-Type ' => 'application/json ' ],
79
80
stream_for (json_encode ($ statistic ->toArray ()))
80
81
);
81
82
82
- // Reset connection and message count
83
- $ currentConnectionCount = collect ($ this ->channelManager ->getChannels ($ appId ))
84
- ->sum (function ($ channel ) {
85
- return count ($ channel ->getSubscribedConnections ());
86
- });
87
-
83
+ $ currentConnectionCount = $ this ->channelManager ->getConnectionCount ($ appId );
88
84
$ statistic ->reset ($ currentConnectionCount );
89
85
}
90
86
}
Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ public function getChannels(string $appId): array
46
46
return $ this ->channels [$ appId ] ?? [];
47
47
}
48
48
49
+ public function getConnectionCount (string $ appId ): int
50
+ {
51
+ return collect ($ this ->getChannels ($ appId ))
52
+ ->sum ->getSubscribedConnections ();
53
+ }
54
+
49
55
public function removeFromAllChannels (ConnectionInterface $ connection )
50
56
{
51
57
if (!isset ($ connection ->app )) {
You can’t perform that action at this time.
0 commit comments