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 | * Constructor |
||
24 | * |
||
25 | * @param StreamInterface $stream |
||
26 | */ |
||
27 | |||
28 | 17 | public function __construct(StreamInterface $stream) |
|
32 | |||
33 | /** |
||
34 | * Reads a WORD from the stream |
||
35 | * |
||
36 | * WORDs are part of SENTENCE. Each WORD has to be encoded in certain way - length of the WORD followed by WORD content. |
||
37 | * Length of the WORD should be given as count of bytes that are going to be sent |
||
38 | * |
||
39 | * @return string The word content, en empty string for end of SENTENCE |
||
40 | */ |
||
41 | 16 | public function readWord(): string |
|
47 | |||
48 | /** |
||
49 | * Write word to stream |
||
50 | * |
||
51 | * @param string $word |
||
52 | * @return int return number of written bytes |
||
53 | */ |
||
54 | 18 | public function writeWord(string $word): int |
|
59 | } |
||
60 |