File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Clue \React \Redis \Client ;
4
+ use Clue \React \Redis \Factory ;
5
+ use Clue \Redis \Protocol \Model \StatusReply ;
6
+
7
+ require __DIR__ . '/../vendor/autoload.php ' ;
8
+
9
+ $ loop = React \EventLoop \Factory::create ();
10
+ $ factory = new Factory ($ loop );
11
+
12
+ $ channel = isset ($ argv [1 ]) ? $ argv [1 ] : 'channel ' ;
13
+ $ message = isset ($ argv [2 ]) ? $ argv [2 ] : 'message ' ;
14
+
15
+ $ factory ->createClient ()->then (function (Client $ client ) use ($ channel , $ message ) {
16
+ $ client ->publish ($ channel , $ message )->then (function ($ received ) {
17
+ echo 'successfully published. Received by ' . $ received . PHP_EOL ;
18
+ });
19
+
20
+ $ client ->end ();
21
+ });
22
+
23
+ $ loop ->run ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Clue \React \Redis \Client ;
4
+ use Clue \React \Redis \Factory ;
5
+ use Clue \Redis \Protocol \Model \StatusReply ;
6
+
7
+ require __DIR__ . '/../vendor/autoload.php ' ;
8
+
9
+ $ loop = React \EventLoop \Factory::create ();
10
+ $ factory = new Factory ($ loop );
11
+
12
+ $ channel = isset ($ argv [1 ]) ? $ argv [1 ] : 'channel ' ;
13
+
14
+ $ factory ->createClient ()->then (function (Client $ client ) use ($ channel ) {
15
+ $ client ->subscribe ($ channel )->then (function () {
16
+ echo 'Now subscribed to channel ' . PHP_EOL ;
17
+ });
18
+
19
+ $ client ->on ('message ' , function ($ channel , $ message ) {
20
+ echo 'Message on ' . $ channel . ': ' . $ message . PHP_EOL ;
21
+ });
22
+ });
23
+
24
+ $ loop ->run ();
You can’t perform that action at this time.
0 commit comments