1 | <?php |
||
21 | class Dispatcher extends AsyncEventEmitter |
||
22 | { |
||
23 | /** |
||
24 | * Stream |
||
25 | * @var SocketInterface |
||
26 | */ |
||
27 | private $stream; |
||
28 | |||
29 | /** |
||
30 | * Deferred requests |
||
31 | * @var array |
||
32 | */ |
||
33 | private $reqs; |
||
34 | |||
35 | /** |
||
36 | * Driver of RESP protocol |
||
37 | * @var DriverInterface |
||
38 | */ |
||
39 | private $protocol; |
||
40 | |||
41 | /** |
||
42 | * Flag of ending |
||
43 | * @var bool |
||
44 | */ |
||
45 | private $ending; |
||
46 | |||
47 | /** |
||
48 | * Flag of closed |
||
49 | * @var bool |
||
50 | */ |
||
51 | private $closed; |
||
52 | |||
53 | /** |
||
54 | * Constructor |
||
55 | * @param LoopInterface $loop |
||
56 | */ |
||
57 | public function __construct(LoopInterface $loop) |
||
69 | |||
70 | /** |
||
71 | * Destructor |
||
72 | */ |
||
73 | public function __destruct() |
||
84 | |||
85 | /** |
||
86 | * Create socket client with connection to Redis database. |
||
87 | * |
||
88 | * @param string $endpoint |
||
89 | * @return SocketInterface |
||
90 | * @throws ExecutionException |
||
91 | */ |
||
92 | protected function createClient($endpoint) |
||
107 | |||
108 | /** |
||
109 | * Get RESP Driver |
||
110 | * @return DriverInterface |
||
111 | */ |
||
112 | public function getDriver() |
||
116 | |||
117 | /** |
||
118 | * Get dispatcher ending flag |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function isEnding() |
||
125 | |||
126 | /** |
||
127 | * Append request |
||
128 | * @param $req |
||
129 | */ |
||
130 | public function appendRequest($req) |
||
134 | |||
135 | /** |
||
136 | * Watch and dispatch streaming |
||
137 | * @param $endpoint |
||
138 | */ |
||
139 | public function watch($endpoint) |
||
156 | |||
157 | /** |
||
158 | * @internal |
||
159 | */ |
||
160 | public function handleConnect() |
||
165 | |||
166 | /** |
||
167 | * @internal |
||
168 | * @param $_ |
||
169 | * @param $data |
||
170 | */ |
||
171 | public function handleData($_, $data) |
||
191 | |||
192 | /** |
||
193 | * @internal |
||
194 | * @param $payload |
||
195 | */ |
||
196 | public function handleRequest($payload) |
||
200 | |||
201 | /** |
||
202 | * @internal |
||
203 | */ |
||
204 | public function handleResponse(ModelInterface $message) |
||
222 | |||
223 | /** |
||
224 | * @internal |
||
225 | */ |
||
226 | public function handleDisconnect() |
||
238 | |||
239 | /** |
||
240 | * @internal |
||
241 | */ |
||
242 | public function handleClose() |
||
254 | } |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.