@@ -137,13 +137,15 @@ public function getGlobalChannels($appId): PromiseInterface
137
137
*/
138
138
public function unsubscribeFromAllChannels (ConnectionInterface $ connection ): PromiseInterface
139
139
{
140
- return $ this ->getGlobalChannels ($ connection ->app ->id )->then (function ($ channels ) use ($ connection ) {
141
- foreach ($ channels as $ channel ) {
142
- $ this ->unsubscribeFromChannel ($ connection , $ channel , new stdClass );
143
- }
144
- })->then (function () use ($ connection ) {
145
- return parent ::unsubscribeFromAllChannels ($ connection );
146
- });
140
+ return $ this ->getGlobalChannels ($ connection ->app ->id )
141
+ ->then (function ($ channels ) use ($ connection ) {
142
+ foreach ($ channels as $ channel ) {
143
+ $ this ->unsubscribeFromChannel ($ connection , $ channel , new stdClass );
144
+ }
145
+ })
146
+ ->then (function () use ($ connection ) {
147
+ return parent ::unsubscribeFromAllChannels ($ connection );
148
+ });
147
149
}
148
150
149
151
/**
@@ -156,15 +158,19 @@ public function unsubscribeFromAllChannels(ConnectionInterface $connection): Pro
156
158
*/
157
159
public function subscribeToChannel (ConnectionInterface $ connection , string $ channelName , stdClass $ payload ): PromiseInterface
158
160
{
159
- return $ this ->subscribeToTopic ($ connection ->app ->id , $ channelName )->then (function () use ($ connection ) {
160
- return $ this ->addConnectionToSet ($ connection , Carbon::now ());
161
- })->then (function () use ($ connection , $ channelName ) {
162
- return $ this ->addChannelToSet ($ connection ->app ->id , $ channelName );
163
- })->then (function () use ($ connection , $ channelName ) {
164
- return $ this ->incrementSubscriptionsCount ($ connection ->app ->id , $ channelName , 1 );
165
- })->then (function () use ($ connection , $ channelName , $ payload ) {
166
- return parent ::subscribeToChannel ($ connection , $ channelName , $ payload );
167
- });
161
+ return $ this ->subscribeToTopic ($ connection ->app ->id , $ channelName )
162
+ ->then (function () use ($ connection ) {
163
+ return $ this ->addConnectionToSet ($ connection , Carbon::now ());
164
+ })
165
+ ->then (function () use ($ connection , $ channelName ) {
166
+ return $ this ->addChannelToSet ($ connection ->app ->id , $ channelName );
167
+ })
168
+ ->then (function () use ($ connection , $ channelName ) {
169
+ return $ this ->incrementSubscriptionsCount ($ connection ->app ->id , $ channelName , 1 );
170
+ })
171
+ ->then (function () use ($ connection , $ channelName , $ payload ) {
172
+ return parent ::subscribeToChannel ($ connection , $ channelName , $ payload );
173
+ });
168
174
}
169
175
170
176
/**
@@ -193,11 +199,14 @@ public function unsubscribeFromChannel(ConnectionInterface $connection, string $
193
199
$ this ->unsubscribeFromTopic ($ connection ->app ->id , $ channelName );
194
200
}
195
201
});
196
- })->then (function () use ($ connection , $ channelName ) {
202
+ })
203
+ ->then (function () use ($ connection , $ channelName ) {
197
204
return $ this ->removeChannelFromSet ($ connection ->app ->id , $ channelName );
198
- })->then (function () use ($ connection ) {
205
+ })
206
+ ->then (function () use ($ connection ) {
199
207
return $ this ->removeConnectionFromSet ($ connection );
200
- })->then (function () use ($ connection , $ channelName , $ payload ) {
208
+ })
209
+ ->then (function () use ($ connection , $ channelName , $ payload ) {
201
210
return parent ::unsubscribeFromChannel ($ connection , $ channelName , $ payload );
202
211
});
203
212
}
@@ -211,9 +220,10 @@ public function unsubscribeFromChannel(ConnectionInterface $connection, string $
211
220
*/
212
221
public function subscribeToApp ($ appId ): PromiseInterface
213
222
{
214
- return $ this ->subscribeToTopic ($ appId )->then (function () use ($ appId ) {
215
- return $ this ->incrementSubscriptionsCount ($ appId );
216
- });
223
+ return $ this ->subscribeToTopic ($ appId )
224
+ ->then (function () use ($ appId ) {
225
+ return $ this ->incrementSubscriptionsCount ($ appId );
226
+ });
217
227
}
218
228
219
229
/**
@@ -225,9 +235,10 @@ public function subscribeToApp($appId): PromiseInterface
225
235
*/
226
236
public function unsubscribeFromApp ($ appId ): PromiseInterface
227
237
{
228
- return $ this ->unsubscribeFromTopic ($ appId )->then (function () use ($ appId ) {
229
- return $ this ->decrementSubscriptionsCount ($ appId );
230
- });
238
+ return $ this ->unsubscribeFromTopic ($ appId )
239
+ ->then (function () use ($ appId ) {
240
+ return $ this ->decrementSubscriptionsCount ($ appId );
241
+ });
231
242
}
232
243
233
244
/**
@@ -297,7 +308,8 @@ public function userJoinedPresenceChannel(ConnectionInterface $connection, stdCl
297
308
return $ this ->storeUserData ($ connection ->app ->id , $ channel , $ connection ->socketId , json_encode ($ user ))
298
309
->then (function () use ($ connection , $ channel , $ user ) {
299
310
return $ this ->addUserSocket ($ connection ->app ->id , $ channel , $ user , $ connection ->socketId );
300
- })->then (function () use ($ connection , $ user , $ channel , $ payload ) {
311
+ })
312
+ ->then (function () use ($ connection , $ user , $ channel , $ payload ) {
301
313
return parent ::userJoinedPresenceChannel ($ connection , $ user , $ channel , $ payload );
302
314
});
303
315
}
@@ -316,7 +328,8 @@ public function userLeftPresenceChannel(ConnectionInterface $connection, stdClas
316
328
return $ this ->removeUserData ($ connection ->app ->id , $ channel , $ connection ->socketId )
317
329
->then (function () use ($ connection , $ channel , $ user ) {
318
330
return $ this ->removeUserSocket ($ connection ->app ->id , $ channel , $ user , $ connection ->socketId );
319
- })->then (function () use ($ connection , $ user , $ channel ) {
331
+ })
332
+ ->then (function () use ($ connection , $ user , $ channel ) {
320
333
return parent ::userLeftPresenceChannel ($ connection , $ user , $ channel );
321
334
});
322
335
}
@@ -370,9 +383,10 @@ public function getChannelsMembersCount($appId, array $channelNames): PromiseInt
370
383
);
371
384
}
372
385
373
- return $ this ->publishClient ->exec ()->then (function ($ data ) use ($ channelNames ) {
374
- return array_combine ($ channelNames , $ data );
375
- });
386
+ return $ this ->publishClient ->exec ()
387
+ ->then (function ($ data ) use ($ channelNames ) {
388
+ return array_combine ($ channelNames , $ data );
389
+ });
376
390
}
377
391
378
392
/**
@@ -399,9 +413,10 @@ public function getMemberSockets($userId, $appId, $channelName): PromiseInterfac
399
413
public function connectionPonged (ConnectionInterface $ connection ): PromiseInterface
400
414
{
401
415
// This will update the score with the current timestamp.
402
- return $ this ->addConnectionToSet ($ connection , Carbon::now ())->then (function () use ($ connection ) {
403
- return parent ::connectionPonged ($ connection );
404
- });
416
+ return $ this ->addConnectionToSet ($ connection , Carbon::now ())
417
+ ->then (function () use ($ connection ) {
418
+ return parent ::connectionPonged ($ connection );
419
+ });
405
420
}
406
421
407
422
/**
0 commit comments