Исходный код вики Сценарии
Версия 1.2 от Alexandr Fokin на 2024/12/24 14:44
Последние авторы
author | version | line-number | content |
---|---|---|---|
1 | |Получение id схемы из binary сообщения|{{code language="c#"}}// c# | ||
2 | public int GetSchemaId(byte[] data) | ||
3 | { | ||
4 | var magicByte = data[0]; | ||
5 | if (magicByte != 0) | ||
6 | { | ||
7 | throw new Exception($"magic byte should be 0, not {magicByte}"); | ||
8 | } | ||
9 | |||
10 | var id = IPAddress.NetworkToHostOrder( | ||
11 | BinaryPrimitives.ReadInt32LittleEndian(data.AsSpan(1, 4))); | ||
12 | |||
13 | return id; | ||
14 | }{{/code}} | ||
15 | | | | ||
16 | | | | ||
17 | |||
18 |