public void HandleClientCommands(int tick, IClientCommandProcessor processor) { foreach (var c in _serverConnections) { c.Value.ProcessCommands(tick, processor); } }
unsafe public void ProcessCommands(int maxTime, IClientCommandProcessor processor) { // Check for time jumps backward in the command stream and reset the queue in case // we find one. (This will happen if the client determines that it has gotten too // far ahead and recalculate the client time.) // TODO : We should be able to do this in a smarter way for (var sequence = commandSequenceProcessed + 1; sequence <= commandSequenceIn; ++sequence) { CommandInfo previous; CommandInfo current; commandsIn.TryGetValue(sequence, out current); commandsIn.TryGetValue(sequence - 1, out previous); if (current != null && previous != null && current.time <= previous.time) { commandSequenceProcessed = sequence - 1; } } for (var sequence = commandSequenceProcessed + 1; sequence <= commandSequenceIn; ++sequence) { CommandInfo info; if (commandsIn.TryGetValue(sequence, out info)) { if (info.time <= maxTime) { fixed(uint *data = info.data) { var reader = new NetworkReader(data, commandSchema); processor.ProcessCommand(ConnectionId, info.time, ref reader); } commandSequenceProcessed = sequence; } else { return; } } } }
private void AddClientCommandProcessor <TInterface>(IClientCommandProcessor processor) where TInterface : IEntityBase { ClientCommandProcessors.Add(H.Get <TInterface>(), processor); }