| | 1 | | using KernelCommunication; |
| | 2 | |
|
| | 3 | | namespace DCL.CRDT |
| | 4 | | { |
| | 5 | | public static class CRDTSerializer |
| | 6 | | { |
| | 7 | | public static void Serialize(BinaryWriter binaryWriter, CRDTMessage message) |
| | 8 | | { |
| 11 | 9 | | byte[] data = (byte[])message.data; |
| 11 | 10 | | int entityId = message.key1; |
| 11 | 11 | | int componentId = message.key2; |
| 11 | 12 | | int dataLength = data?.Length ?? 0; |
| | 13 | |
|
| 11 | 14 | | binaryWriter.WriteInt32(entityId); |
| 11 | 15 | | binaryWriter.WriteInt32(componentId); |
| 11 | 16 | | binaryWriter.WriteInt64(message.timestamp); |
| 11 | 17 | | binaryWriter.WriteInt32(dataLength); |
| | 18 | |
|
| 11 | 19 | | if (dataLength > 0) |
| | 20 | | { |
| 8 | 21 | | binaryWriter.WriteBytes(data); |
| | 22 | | } |
| 11 | 23 | | } |
| | 24 | | } |
| | 25 | | } |