public void Submit(Guid clientId, int playerIndex, Cmd cmd, ServerEventHandler <Cmd> callback) { cmd = m_serializer.DeepClone(cmd); Error error = new Error(); error.Code = StatusCode.OK; if (cmd.Code == CmdCode.LeaveRoom) { error.Code = StatusCode.NotAllowed; error.Message = "Use LeaveRoom method instead"; } else { if (!m_initialized) { error.Code = StatusCode.NotAllowed; error.Message = "Match is not initialized"; } else if (!enabled) { error.Code = StatusCode.Paused; error.Message = "Match is paused"; } else { m_replay.Record(playerIndex, cmd, m_tick); m_engine.Submit(playerIndex, cmd); // if I will use RTT Ticks then it will be possible to reverse order of commands sent by client (which is BAD!) } } if (m_lag == 0) { callback(error, cmd); } else { m_job.Submit(() => { Thread.Sleep(m_lag); return(null); }, result => callback(error, cmd)); } }
private void OnEngineCommandSubmitted(int playerIndex, Cmd cmd) { m_replay.Record(playerIndex, cmd, m_tick); }