private NetworkMessage SerializeSnapshot(ICommandSnapshot commandSnapshot)
        {
            SerializableNetworkCommand serializableCommand =
                new SerializableNetworkCommand(_sequenceIndex.index, new SerializableCommand(commandSnapshot));

            _sequenceIndex.index++;

            return(_networkMessageSerializer.Serialize(serializableCommand, MessageTags.kNetworkCommand));
        }
Exemplo n.º 2
0
        protected void DoSerialize(MemoryStream ms, int messageType, object messageBody)
        {
            byte[] bytes = BitConverter.GetBytes(messageType);
            if (!LittleEndian)
            {
                ms.WriteByte(bytes[3]);
                ms.WriteByte(bytes[2]);
                ms.WriteByte(bytes[1]);
                ms.WriteByte(bytes[0]);
            }
            else
            {
                ms.WriteByte(bytes[0]);
                ms.WriteByte(bytes[1]);
                ms.WriteByte(bytes[2]);
                ms.WriteByte(bytes[3]);
            }


            var send = _serializer.Serialize(ms, messageType, messageBody);
        }
        protected int DoSerialize(MemoryStream ms, int messageType, object messageBody)
        {
            if (!LittleEndian)
            {
                ms.WriteByte((byte)(messageType >> 24));
                ms.WriteByte((byte)(messageType >> 16));
                ms.WriteByte((byte)(messageType >> 8));
                ms.WriteByte((byte)messageType);
            }
            else
            {
                ms.WriteByte((byte)messageType);
                ms.WriteByte((byte)(messageType >> 8));
                ms.WriteByte((byte)(messageType >> 16));
                ms.WriteByte((byte)(messageType >> 24));
            }


            int send = (int)_serializer.Serialize(ms, messageType, messageBody);

            return(send + 4);
        }