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

            _sequenceIndex.index++;

            return(_networkMessageSerializer.Serialize(serializableCommand, MessageTags.kNetworkCommand));
        }
Пример #2
0
        private void HandleMessageReceived(NetworkMessage networkMessage)
        {
            // Note: We enqueue this command even as server, because we want clients to broadcast all their events
            // This may change.
            // For now, don't handle collisions with commands either.
            // We will have to handle versioning but we need to decide what to do with master / clients.

            SerializableNetworkCommand serializableCommand =
                _messageSerializer.Deserialize <SerializableNetworkCommand>(networkMessage);

            _commandQueue.Enqueue(serializableCommand.command.commandType,
                                  serializableCommand.command.dataType,
                                  serializableCommand.command.data,
                                  CommandSource.Network);
        }