| | 1 | | using KernelCommunication; |
| | 2 | |
|
| | 3 | | namespace DCL.CRDT |
| | 4 | | { |
| | 5 | | // Deserialize CRDT binary messages (BigEndian) |
| | 6 | | public static class CRDTDeserializer |
| | 7 | | { |
| 1 | 8 | | internal static readonly CRDTComponentMessageHeader componentHeader = new CRDTComponentMessageHeader(); |
| | 9 | |
|
| | 10 | | public static CRDTMessage Deserialize(IBinaryReader dataReader) |
| | 11 | | { |
| 20 | 12 | | componentHeader.entityId = dataReader.ReadInt32(); |
| 20 | 13 | | componentHeader.componentClassId = dataReader.ReadInt32(); |
| 20 | 14 | | componentHeader.timestamp = dataReader.ReadInt64(); |
| 20 | 15 | | componentHeader.dataLength = dataReader.ReadInt32(); |
| | 16 | |
|
| 20 | 17 | | byte[] data = null; |
| 20 | 18 | | if (componentHeader.dataLength > 0) |
| | 19 | | { |
| 16 | 20 | | data = dataReader.ReadBytes(componentHeader.dataLength); |
| | 21 | | } |
| | 22 | |
|
| 20 | 23 | | return new CRDTMessage() |
| | 24 | | { |
| | 25 | | key1 = componentHeader.entityId, |
| | 26 | | key2 = componentHeader.componentClassId, |
| | 27 | | timestamp = componentHeader.timestamp, |
| | 28 | | data = data |
| | 29 | | }; |
| | 30 | | } |
| | 31 | | } |
| | 32 | | } |