1 | <?php |
||
21 | class StreamedClientIo extends AbstractClientIo |
||
22 | { |
||
23 | /** |
||
24 | * Read attempts count |
||
25 | */ |
||
26 | const READ_ATTEMPTS = 2; |
||
27 | |||
28 | /** |
||
29 | * Amount of read attempts |
||
30 | * |
||
31 | * @var int |
||
32 | */ |
||
33 | private $readAttempts = self::READ_ATTEMPTS; |
||
34 | |||
35 | /** |
||
36 | * Remote socket address |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $remoteAddress; |
||
41 | |||
42 | 26 | /** {@inheritdoc} */ |
|
43 | protected function readRawDataIntoPicker(FramePickerInterface $picker, $isOutOfBand) |
||
47 | |||
48 | 5 | /** {@inheritdoc} */ |
|
49 | protected function writeRawData($data, $isOutOfBand) |
||
62 | |||
63 | 4 | /** |
|
64 | 1 | * Verifies that send operation completed successfully |
|
65 | 1 | * |
|
66 | 1 | * @param string $data Data for remote side |
|
67 | * @param int|bool $sendResult Return value from send function |
||
68 | * |
||
69 | * @return void |
||
70 | 3 | * @throws NetworkSocketException |
|
71 | 1 | */ |
|
72 | private function verifySendResult($data, $sendResult) |
||
85 | |||
86 | 25 | /** {@inheritdoc} */ |
|
87 | 25 | protected function isConnected() |
|
91 | |||
92 | /** {@inheritdoc} */ |
||
93 | 25 | protected function getRemoteAddress() |
|
104 | |||
105 | /** {@inheritdoc} */ |
||
106 | protected function canReachFrame() |
||
110 | |||
111 | 1 | /** |
|
112 | 1 | * Read OOB data from socket |
|
113 | 1 | * |
|
114 | 1 | * @param FramePickerInterface $picker |
|
115 | * |
||
116 | * @return string |
||
117 | 1 | */ |
|
118 | private function readOobData(FramePickerInterface $picker) |
||
128 | |||
129 | /** |
||
130 | 25 | * Read regular data |
|
131 | * |
||
132 | 25 | * @param FramePickerInterface $picker Picker to read data into |
|
133 | 25 | * |
|
134 | * @return string |
||
135 | */ |
||
136 | private function readRegularData(FramePickerInterface $picker) |
||
165 | |||
166 | /** |
||
167 | * Return first byte from socket buffer |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | private function getDataInSocket() |
||
175 | |||
176 | 24 | /** |
|
177 | 24 | * Checks whether data read from stream buffer can be filled later |
|
178 | 5 | * |
|
179 | 5 | * @param string $data Read data |
|
180 | * |
||
181 | * @return bool |
||
182 | 24 | */ |
|
183 | private function isReadDataActuallyEmpty($data) |
||
193 | 24 | ||
194 | /** |
||
195 | 24 | * Calculate attempts value |
|
196 | 24 | * |
|
197 | 20 | * @param array $context Read context |
|
198 | 24 | * @param int $currentAttempts Current attempts counter |
|
199 | * |
||
200 | * @return int |
||
201 | */ |
||
202 | private function resolveReadAttempts(array $context, $currentAttempts) |
||
210 | 1 | ||
211 | /** |
||
212 | 1 | * Write out-of-band data |
|
213 | 1 | * |
|
214 | 1 | * @param resource $socket Socket resource |
|
215 | 1 | * @param string $data Data to write |
|
216 | 1 | * |
|
217 | * @return int Amount of written bytes |
||
218 | */ |
||
219 | private function writeOobData($socket, $data) |
||
236 | |||
237 | /** |
||
238 | 37 | * Return remote address if we connected or false otherwise |
|
239 | * |
||
240 | 37 | * @return string|null |
|
241 | */ |
||
242 | 37 | private function resolveRemoteAddress() |
|
248 | } |
||
249 |