@@ -66,14 +66,17 @@ public function __construct()
66
66
* Boot the RedisClient, initializing the connections.
67
67
*
68
68
* @param LoopInterface $loop
69
+ * @param string|null $factoryClass
69
70
* @return ReplicationInterface
70
71
*/
71
- public function boot (LoopInterface $ loop ): ReplicationInterface
72
+ public function boot (LoopInterface $ loop, $ factoryClass = null ): ReplicationInterface
72
73
{
74
+ $ factoryClass = $ factoryClass ?: Factory::class;
75
+
73
76
$ this ->loop = $ loop ;
74
77
75
78
$ connectionUri = $ this ->getConnectionUri ();
76
- $ factory = new Factory ($ this ->loop );
79
+ $ factory = new $ factoryClass ($ this ->loop );
77
80
78
81
$ this ->publishClient = $ factory ->createLazyClient ($ connectionUri );
79
82
$ this ->subscribeClient = $ factory ->createLazyClient ($ connectionUri );
@@ -108,7 +111,7 @@ protected function onMessage(string $redisChannel, string $payload)
108
111
// We need to put the channel name in the payload.
109
112
// We strip the app ID from the channel name, websocket clients
110
113
// expect the channel name to not include the app ID.
111
- $ payload ->channel = Str::after ($ redisChannel , "$ appId: " );
114
+ $ payload ->channel = Str::after ($ redisChannel , "{ $ appId} : " );
112
115
113
116
$ channelManager = app (ChannelManager::class);
114
117
@@ -296,4 +299,34 @@ protected function getConnectionUri()
296
299
297
300
return "redis:// {$ host }: {$ port }" .($ query ? "? {$ query }" : '' );
298
301
}
302
+
303
+ /**
304
+ * Get the Subscribe client instance.
305
+ *
306
+ * @return Client
307
+ */
308
+ public function getSubscribeClient ()
309
+ {
310
+ return $ this ->subscribeClient ;
311
+ }
312
+
313
+ /**
314
+ * Get the Publish client instance.
315
+ *
316
+ * @return Client
317
+ */
318
+ public function getPublishClient ()
319
+ {
320
+ return $ this ->publishClient ;
321
+ }
322
+
323
+ /**
324
+ * Get the unique identifier for the server.
325
+ *
326
+ * @return string
327
+ */
328
+ public function getServerId ()
329
+ {
330
+ return $ this ->serverId ;
331
+ }
299
332
}
0 commit comments