@@ -111,12 +111,16 @@ public function findOrCreate($appId, string $channel)
111
111
*/
112
112
public function getLocalConnections (): PromiseInterface
113
113
{
114
- $ connections = collect ($ this ->channels )->map (function ($ channelsWithConnections , $ appId ) {
115
- return collect ($ channelsWithConnections )->values ();
116
- })->values ()->collapse ()
117
- ->map (function ($ channel ) {
118
- return collect ($ channel ->getConnections ());
119
- })->values ()->collapse ()->toArray ();
114
+ $ connections = collect ($ this ->channels )
115
+ ->map (function ($ channelsWithConnections , $ appId ) {
116
+ return collect ($ channelsWithConnections )->values ();
117
+ })
118
+ ->values ()->collapse ()
119
+ ->map (function ($ channel ) {
120
+ return collect ($ channel ->getConnections ());
121
+ })
122
+ ->values ()->collapse ()
123
+ ->toArray ();
120
124
121
125
return Helpers::createFulfilledPromise ($ connections );
122
126
}
@@ -162,9 +166,11 @@ public function unsubscribeFromAllChannels(ConnectionInterface $connection): Pro
162
166
$ this ->getLocalChannels ($ connection ->app ->id )->then (function ($ channels ) use ($ connection ) {
163
167
collect ($ channels )->each ->unsubscribe ($ connection );
164
168
165
- collect ($ channels )->reject ->hasConnections ()->each (function (Channel $ channel , string $ channelName ) use ($ connection ) {
166
- unset($ this ->channels [$ connection ->app ->id ][$ channelName ]);
167
- });
169
+ collect ($ channels )
170
+ ->reject ->hasConnections ()
171
+ ->each (function (Channel $ channel , string $ channelName ) use ($ connection ) {
172
+ unset($ this ->channels [$ connection ->app ->id ][$ channelName ]);
173
+ });
168
174
});
169
175
170
176
$ this ->getLocalChannels ($ connection ->app ->id )->then (function ($ channels ) use ($ connection ) {
@@ -249,9 +255,11 @@ public function getLocalConnectionsCount($appId, string $channelName = null): Pr
249
255
return $ collection ->filter (function (Channel $ channel ) use ($ channelName ) {
250
256
return $ channel ->getName () === $ channelName ;
251
257
});
252
- })->flatMap (function (Channel $ channel ) {
258
+ })
259
+ ->flatMap (function (Channel $ channel ) {
253
260
return collect ($ channel ->getConnections ())->pluck ('socketId ' );
254
- })->unique ()->count ();
261
+ })
262
+ ->unique ()->count ();
255
263
});
256
264
}
257
265
@@ -370,13 +378,14 @@ public function getChannelMember(ConnectionInterface $connection, string $channe
370
378
*/
371
379
public function getChannelsMembersCount ($ appId , array $ channelNames ): PromiseInterface
372
380
{
373
- $ results = collect ($ channelNames )->reduce (function ($ results , $ channel ) use ($ appId ) {
374
- $ results [$ channel ] = isset ($ this ->users ["{$ appId }: {$ channel }" ])
375
- ? count ($ this ->users ["{$ appId }: {$ channel }" ])
376
- : 0 ;
377
-
378
- return $ results ;
379
- }, []);
381
+ $ results = collect ($ channelNames )
382
+ ->reduce (function ($ results , $ channel ) use ($ appId ) {
383
+ $ results [$ channel ] = isset ($ this ->users ["{$ appId }: {$ channel }" ])
384
+ ? count ($ this ->users ["{$ appId }: {$ channel }" ])
385
+ : 0 ;
386
+
387
+ return $ results ;
388
+ }, []);
380
389
381
390
return Helpers::createFulfilledPromise ($ results );
382
391
}
0 commit comments