13
13
use RuntimeException ;
14
14
use React \Promise \Deferred ;
15
15
use Clue \Redis \Protocol \Model \ErrorReply ;
16
+ use Clue \Redis \Protocol \Model \ModelInterface ;
16
17
17
18
class Client extends EventEmitter
18
19
{
@@ -47,7 +48,7 @@ public function __construct(Stream $stream, ParserInterface $parser = null, Seri
47
48
48
49
foreach ($ models as $ data ) {
49
50
try {
50
- $ that ->handleReply ($ data );
51
+ $ that ->handleMessage ($ data );
51
52
}
52
53
catch (UnderflowException $ error ) {
53
54
$ that ->emit ('error ' , array ($ error ));
@@ -86,9 +87,9 @@ public function __call($name, $args)
86
87
return $ request ->promise ();
87
88
}
88
89
89
- public function handleReply ( $ data )
90
+ public function handleMessage ( ModelInterface $ message )
90
91
{
91
- $ this ->emit ('message ' , array ($ data , $ this ));
92
+ $ this ->emit ('message ' , array ($ message , $ this ));
92
93
93
94
if (!$ this ->requests ) {
94
95
throw new UnderflowException ('Unexpected reply received, no matching request found ' );
@@ -97,10 +98,10 @@ public function handleReply($data)
97
98
$ request = array_shift ($ this ->requests );
98
99
/* @var $request Deferred */
99
100
100
- if ($ data instanceof ErrorReply) {
101
- $ request ->reject ($ data );
101
+ if ($ message instanceof ErrorReply) {
102
+ $ request ->reject ($ message );
102
103
} else {
103
- $ request ->resolve ($ data ->getValueNative ());
104
+ $ request ->resolve ($ message ->getValueNative ());
104
105
}
105
106
106
107
if ($ this ->ending && !$ this ->isBusy ()) {
0 commit comments