1 | <?php |
||
6 | class SplitPackageUdp extends UdpSocket |
||
7 | { |
||
8 | |||
9 | public const CHUNK_MAGIC = "\x1e\x0f"; |
||
10 | |||
11 | protected $chunkSize = 8144; |
||
12 | |||
13 | public function write(string $message, int $length = null): int |
||
23 | |||
24 | /** |
||
25 | * chunk format: |
||
26 | * Chunked magic bytes - 2 bytes: 0x1e 0x0f |
||
27 | * Message ID - 8 bytes: Must be the same for every chunk of this message. Identifying the whole message and is used to reassemble the chunks later |
||
28 | * Sequence number - 1 byte: The sequence number of this chunk. Starting at 0 and always less than the sequence count |
||
29 | * Sequence count - 1 byte: Total number of chunks this message has |
||
30 | * Message chunk |
||
31 | * |
||
32 | * @param string $buffer |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | protected function splitToChunks(string $buffer): array |
||
48 | |||
49 | protected function generateId(): string |
||
53 | } |
||
54 |