1 | <?php |
||
15 | class APIConnector |
||
16 | { |
||
17 | /** |
||
18 | * @var StreamInterface $stream The stream used to communicate with the router |
||
19 | */ |
||
20 | protected $stream; |
||
21 | |||
22 | /** |
||
23 | * APIConnector constructor. |
||
24 | * |
||
25 | * @param \RouterOS\Interfaces\StreamInterface $stream |
||
26 | */ |
||
27 | 24 | public function __construct(StreamInterface $stream) |
|
31 | |||
32 | /** |
||
33 | * Close stream connection |
||
34 | * |
||
35 | * @return void |
||
36 | */ |
||
37 | public function close(): void |
||
41 | |||
42 | /** |
||
43 | * Reads a WORD from the stream |
||
44 | * |
||
45 | * WORDs are part of SENTENCE. Each WORD has to be encoded in certain way - length of the WORD followed by WORD content. |
||
46 | * Length of the WORD should be given as count of bytes that are going to be sent |
||
47 | * |
||
48 | * @return string The word content, en empty string for end of SENTENCE |
||
49 | */ |
||
50 | 23 | public function readWord(): string |
|
56 | |||
57 | /** |
||
58 | * Write word to stream |
||
59 | * |
||
60 | * @param string $word |
||
61 | * |
||
62 | * @return int return number of written bytes |
||
63 | */ |
||
64 | 25 | public function writeWord(string $word): int |
|
69 | } |
||
70 |