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