1414use React \Promise \Deferred ;
1515use Clue \Redis \Protocol \Model \ErrorReply ;
1616use Clue \Redis \Protocol \Model \ModelInterface ;
17+ use Clue \Redis \Protocol \Model \StatusReply ;
1718
1819class StreamingClient extends EventEmitter implements Client
1920{
@@ -24,6 +25,8 @@ class StreamingClient extends EventEmitter implements Client
2425 private $ ending = false ;
2526 private $ closed = false ;
2627
28+ private $ monitoring = false ;
29+
2730 public function __construct (Stream $ stream , ParserInterface $ parser = null , SerializerInterface $ serializer = null )
2831 {
2932 if ($ parser === null || $ serializer === null ) {
@@ -78,13 +81,25 @@ public function __call($name, $args)
7881 $ this ->requests []= $ request ;
7982 }
8083
84+ if (strtolower ($ name ) === 'monitor ' ) {
85+ $ monitoring =& $ this ->monitoring ;
86+ $ request ->then (function () use (&$ monitoring ) {
87+ $ monitoring = true ;
88+ });
89+ }
90+
8191 return $ request ->promise ();
8292 }
8393
8494 public function handleMessage (ModelInterface $ message )
8595 {
8696 $ this ->emit ('data ' , array ($ message , $ this ));
8797
98+ if ($ this ->monitoring && $ message instanceof StatusReply) {
99+ $ this ->emit ('monitor ' , array ($ message , $ this ));
100+ return ;
101+ }
102+
88103 if (!$ this ->requests ) {
89104 throw new UnderflowException ('Unexpected reply received, no matching request found ' );
90105 }
0 commit comments