public void Init(PacketObject msg, int rFrame) { var p = msg.BuildPacket(); packet = Packet.Build(p.header, p.bytes, false); cache = PacketObject.Create(packet); Frame = rFrame; }
public Command Reset(PacketObject rObject) { if (null == rObject) { return(this); } var p = rObject.BuildPacket(); packet = Packet.Build(p.header, p.bytes, false); cache = PacketObject.Create(packet); return(this); }
public virtual void Send(PacketObject packet) { if (connected && packet != null && !packet.destroyed) { #if UNITY_EDITOR if (LocalServer.instance.AutoHandlePacket(packet.GetType(), this)) { return; } #endif var p = packet.BuildPacket(); #if DEVELOPMENT_BUILD || UNITY_EDITOR var f = ConfigManager.Get <ProtocolLoggerFilter>(packet._ID); if (!f || !f.disabled) { if (!f || !f.noDetail) { try { Logger.Log(LogType.SEND, "Send: [{0}:{1}-{2},{3}] {4}", p.ID, p.dataSize, Level.realTime, packet._name, LitJson.JsonMapper.ToJson(packet, true, 5, true)); } catch (Exception e) { Logger.Log(LogType.SEND, "Send: [{0}:{1}-{2},{3}]", p.ID, p.dataSize, Level.realTime, packet._name); Logger.LogException(e); } } else { Logger.Log(LogType.SEND, "Send: [{0}:{1}-{2},{3}]", p.ID, p.dataSize, Level.realTime, packet._name); } if (f && f.cpp) { packet.LogCppString(); } } #endif m_sender.Send(p); } if (!packet.dontDestroyOnSend) { packet.Destroy(); } }
public void Record(PacketObject rPacket, int rFrame) { if (m_pending) { return; } lock (packets) { var p = rPacket.BuildPacket(); var packet = Packet.Build(p.header, p.bytes, false); var obj = PacketObject.Create(packet); if (m_useThread) { packets.Enqueue(ProtocolEntry.Create(obj, rFrame)); } else { gameRecorder.Record(obj, rFrame); } } }