private void OnLoginRequest(Message msg) { var req = (LoginRequest)msg.Body; this.name = req.Name; this.actorId = this.scene.AllocateCube(this.name); if (this.actorId > 0) { logger.Info("Login succeeded: {0}, ObjectId: {1}", this.name, this.actorId); var fbb = new FlatBufferBuilder(1024); var oRes = LoginResponse.CreateLoginResponse(fbb, this.actorId); LoginResponse.FinishLoginResponseBuffer(fbb, oRes); WriteBytes(FlatBufferExtensions.ToProtocolMessage(fbb, ServerMessageIds.LoginResponse)); foreach (var bytes in this.scene.GetSceneData()) { WriteBytes(bytes); } } else { logger.Info("Login failed."); } }
public void TestFlatBufferConsistency() { var random = new Random(); var recorder = new FlatBufferRecorder(); var replayer = new FlatBufferReplayer(); var schema = new MessageSchema(); schema.Register(1, SynchronizeSceneData.GetRootAsSynchronizeSceneData); var processor = new MessageProcessor(schema); processor.Attach(1, msg => OnProcessMessage(recorder, replayer, msg)); for (var time = 0; time < TotalRunTime; time += RecordInterval) { var fbb = RandomRecord(random, recorder, time); if (fbb != null) { var bytes = FlatBufferExtensions.ToProtocolMessage(fbb, 1); processor.Enqueue(bytes); processor.Process(); } } }
public void Input(Command command) { var time = this.replayer.Scene.ElapsedTime; var fbb = new FlatBufferBuilder(1024); var oInput = InputRequest.CreateInputRequest(fbb, time, command); InputRequest.FinishInputRequestBuffer(fbb, oInput); WriteBytes(FlatBufferExtensions.ToProtocolMessage(fbb, ClientMessageIds.InputRequest)); Debug.Log(string.Format("Input {0} {1}ms", command, time)); }
public void Login() { var fbb = new FlatBufferBuilder(1024); var oName = fbb.CreateString(this.name); var oLogin = LoginRequest.CreateLoginRequest(fbb, oName); LoginRequest.FinishLoginRequestBuffer(fbb, oLogin); WriteBytes(FlatBufferExtensions.ToProtocolMessage(fbb, ClientMessageIds.LoginRequest)); Debug.Log("Login"); }