1 | <?php |
||
17 | class StreamedClientIo extends AbstractClientIo |
||
18 | { |
||
19 | /** |
||
20 | * Read attempts count |
||
21 | */ |
||
22 | const READ_ATTEMPTS = 2; |
||
23 | |||
24 | /** |
||
25 | * Amount of read attempts |
||
26 | * |
||
27 | * @var int |
||
28 | */ |
||
29 | private $readAttempts = self::READ_ATTEMPTS; |
||
30 | |||
31 | /** |
||
32 | * Remote socket address |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $remoteAddress; |
||
37 | |||
38 | /** {@inheritdoc} */ |
||
39 | 25 | protected function readRawDataIntoPicker(FramePickerInterface $picker, $isOutOfBand) |
|
43 | |||
44 | 25 | /** |
|
45 | 25 | * Read OOB data from socket |
|
46 | 25 | * |
|
47 | 25 | * @param FramePickerInterface $picker |
|
48 | * |
||
49 | * @return string |
||
50 | 25 | */ |
|
51 | 25 | private function readOobData(FramePickerInterface $picker) |
|
61 | |||
62 | /** |
||
63 | * Read regular data |
||
64 | * |
||
65 | * @param FramePickerInterface $picker Picker to read data into |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | private function readRegularData(FramePickerInterface $picker) |
||
92 | |||
93 | 3 | /** |
|
94 | 2 | * Calculate attempts value |
|
95 | 1 | * |
|
96 | * @param array $context Read context |
||
97 | 2 | * @param int $currentAttempts Current attempts counter |
|
98 | * |
||
99 | * @return int |
||
100 | */ |
||
101 | 34 | private function resolveReadAttempts(array $context, $currentAttempts) |
|
109 | 24 | ||
110 | 24 | /** {@inheritdoc} */ |
|
111 | 24 | protected function writeRawData($data, $isOutOfBand) |
|
129 | 5 | ||
130 | /** {@inheritdoc} */ |
||
131 | 24 | protected function isConnected() |
|
135 | 2 | ||
136 | /** {@inheritdoc} */ |
||
137 | 2 | protected function getRemoteAddress() |
|
145 | 25 | ||
146 | /** |
||
147 | 25 | * Checks whether data read from stream buffer can be filled later |
|
148 | * |
||
149 | * @param string $data Read data |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | private function isReadDataActuallyEmpty($data) |
||
163 | |||
164 | /** {@inheritdoc} */ |
||
165 | protected function canReachFrame() |
||
169 | |||
170 | 1 | /** |
|
171 | 1 | * Return first byte from socket buffer |
|
172 | 1 | * |
|
173 | 1 | * @return string |
|
174 | 1 | */ |
|
175 | 1 | private function getDataInSocket() |
|
179 | 1 | ||
180 | 1 | /** |
|
181 | * Return remote address if we connected or false otherwise |
||
182 | 1 | * |
|
183 | * @return string|bool |
||
184 | */ |
||
185 | private function resolveRemoteAddress() |
||
189 | |||
190 | /** |
||
191 | * Write out-of-band data |
||
192 | * |
||
193 | * @param resource $socket Socket resource |
||
194 | * @param string $data Data to write |
||
195 | * |
||
196 | * @return int Amount of written bytes |
||
197 | */ |
||
198 | private function writeOobData($socket, $data) |
||
214 | } |
||
215 |