1 | <?php |
||
15 | abstract class AbstractFramePicker implements FramePickerInterface |
||
16 | { |
||
17 | /** |
||
18 | * Flag, whether framePicker is finished |
||
19 | * |
||
20 | * @var bool |
||
21 | */ |
||
22 | private $isFinished; |
||
23 | |||
24 | /** |
||
25 | * Frame with data for this picker |
||
26 | * |
||
27 | * @var FrameInterface |
||
28 | */ |
||
29 | private $frame; |
||
30 | |||
31 | /** |
||
32 | * Collected data for this frame |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $buffer; |
||
37 | |||
38 | /** |
||
39 | * Client's address sent this data |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $remoteAddress; |
||
44 | |||
45 | /** |
||
46 | * AbstractFramePicker constructor. |
||
47 | */ |
||
48 | 122 | public function __construct() |
|
53 | |||
54 | /** {@inheritdoc} */ |
||
55 | 75 | public function isEof() |
|
59 | |||
60 | /** {@inheritdoc} */ |
||
61 | 72 | public function pickUpData($chunk, $remoteAddress) |
|
74 | |||
75 | /** |
||
76 | * Process raw network data. Data should be used to determine end of this concrete framePicker |
||
77 | * |
||
78 | * @param string $chunk Chunk read from socket |
||
79 | * @param string $remoteAddress Client's address sent this data |
||
80 | * @param string &$buffer Pointer to internal buffer for collecting data |
||
81 | * |
||
82 | * @return string Unprocessed data after the end of frame |
||
83 | */ |
||
84 | abstract protected function doHandleData($chunk, $remoteAddress, &$buffer); |
||
85 | |||
86 | /** |
||
87 | * Create frame for picked up data |
||
88 | * |
||
89 | * @param string $buffer Buffer with collected data |
||
90 | * @param string $remoteAddress Remote socket address these data from |
||
91 | * |
||
92 | * @return FrameInterface |
||
93 | */ |
||
94 | abstract protected function doCreateFrame($buffer, $remoteAddress); |
||
95 | |||
96 | /** |
||
97 | * Sets finished flag |
||
98 | * |
||
99 | * @param boolean $isFinished Flag whether framePicker is finished |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | 59 | protected function setFinished($isFinished) |
|
107 | |||
108 | /** {@inheritdoc} */ |
||
109 | 72 | public function createFrame() |
|
117 | } |
||
118 |