Исходный код вики Сценарии
Редактировал(а) Alexandr Fokin 2024/12/24 14:44
Последние авторы
| author | version | line-number | content |
|---|---|---|---|
| 1 | |(% style="width:215px" %)Получение id схемы из binary сообщения|(% style="width:1278px" %){{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 | |(% style="width:215px" %) |(% style="width:1278px" %) | ||
| 16 | |(% style="width:215px" %) |(% style="width:1278px" %) | ||
| 17 | |||
| 18 |