1 | <?php |
||
25 | class Connection implements ConnectionInterface, WireSubscriberInterface |
||
26 | { |
||
27 | const STATUS_CLOSED = 'closed'; |
||
28 | const STATUS_READY = 'ready'; |
||
29 | const STATUS_BLOCKED = 'blocked'; |
||
30 | |||
31 | /** |
||
32 | * @var Url |
||
33 | */ |
||
34 | private $url; |
||
35 | |||
36 | /** |
||
37 | * @var WireInterface |
||
38 | */ |
||
39 | private $wire; |
||
40 | |||
41 | /** |
||
42 | * @var AuthenticatorInterface |
||
43 | */ |
||
44 | private $authenticator; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $status; |
||
50 | |||
51 | /** |
||
52 | * @var Channel[] |
||
53 | */ |
||
54 | private $channels = []; |
||
55 | |||
56 | /** |
||
57 | * @var array |
||
58 | */ |
||
59 | private $capabilities = []; |
||
60 | |||
61 | /** |
||
62 | * @param Url|string $url |
||
63 | * @param WireInterface $wire |
||
64 | * @param AuthenticatorInterface $authenticator |
||
65 | */ |
||
66 | 31 | public function __construct(Url $url, WireInterface $wire, AuthenticatorInterface $authenticator = null) |
|
72 | |||
73 | /** |
||
74 | * Connection status. See STATUS_* constants for possible values. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 4 | public function getStatus() |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 21 | public function open() |
|
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | 19 | public function channel($id = null) |
|
123 | |||
124 | /** |
||
125 | * @return int |
||
126 | */ |
||
127 | 18 | private function allocateChannelNumber() |
|
131 | |||
132 | /** |
||
133 | * @param int $id |
||
134 | * |
||
135 | * @return bool |
||
136 | */ |
||
137 | 19 | private function isChannelNumberValid($id) |
|
141 | |||
142 | /** |
||
143 | * @param int $id |
||
144 | * |
||
145 | * @return Channel |
||
146 | */ |
||
147 | 18 | private function openChannel($id) |
|
156 | |||
157 | /** |
||
158 | * {@inheritdoc} |
||
159 | */ |
||
160 | 18 | public function close($code = 0, $reason = '') |
|
171 | |||
172 | /** |
||
173 | * {@inheritdoc} |
||
174 | */ |
||
175 | 1 | public function isSupported($capability) |
|
182 | |||
183 | /** |
||
184 | * {@inheritdoc} |
||
185 | */ |
||
186 | 10 | public function serve($blocking = true) |
|
192 | |||
193 | /** |
||
194 | * Sends frame to the service channel (#0). |
||
195 | * |
||
196 | * @param Frame $frame |
||
197 | * |
||
198 | * @return $this |
||
199 | */ |
||
200 | 27 | private function send(Frame $frame) |
|
206 | |||
207 | /** |
||
208 | * Wait for a frame in the service channel (#0). |
||
209 | * |
||
210 | * @param string|array $type |
||
211 | * |
||
212 | * @return Frame |
||
213 | */ |
||
214 | 22 | private function wait($type) |
|
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | 26 | public function dispatch(Frame $frame) |
|
236 | |||
237 | /** |
||
238 | * This frame is the first frame received from server. |
||
239 | * It provides server details and requests client credentials. |
||
240 | * |
||
241 | * @param ConnectionStart $frame |
||
242 | */ |
||
243 | 20 | private function onConnectionStart(ConnectionStart $frame) |
|
263 | |||
264 | /** |
||
265 | * @return array |
||
266 | */ |
||
267 | 20 | private function getClientProperties() |
|
283 | |||
284 | /** |
||
285 | * This frame is received to setup connection preferences, like max frame size, |
||
286 | * max number of channel and heartbeat delay. |
||
287 | * |
||
288 | * Values in the request can be lowered by client. |
||
289 | * |
||
290 | * @param ConnectionTune $frame |
||
291 | */ |
||
292 | private function onConnectionTune(ConnectionTune $frame) |
||
307 | |||
308 | /** |
||
309 | * This frame is received once server decide to close connection, normally because an unrecoverable error occur. |
||
310 | * |
||
311 | * @param ConnectionClose $frame |
||
312 | * |
||
313 | * @throws AMQPException |
||
314 | */ |
||
315 | 3 | private function onConnectionClose(ConnectionClose $frame) |
|
326 | |||
327 | /** |
||
328 | * This frame is received once server decide to suspend connection, for example because server |
||
329 | * run out of memory and can not provide service for the connection. When this happen consumer |
||
330 | * suppose to suspend all activities until connection.unblocked is received. |
||
331 | * |
||
332 | * @param ConnectionBlocked $frame |
||
333 | */ |
||
334 | 1 | private function onConnectionBlocked(ConnectionBlocked $frame) |
|
338 | |||
339 | /** |
||
340 | * This frame is received once connection returns back to normal state after being suspended. |
||
341 | * See onConnectionBlocked above. |
||
342 | * |
||
343 | * @param ConnectionUnblocked $frame |
||
344 | */ |
||
345 | 1 | private function onConnectionUnblocked(ConnectionUnblocked $frame) |
|
349 | |||
350 | /** |
||
351 | * Opens connection if closed. |
||
352 | */ |
||
353 | 19 | private function openIfClosed() |
|
359 | } |
||
360 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.