public void SendMsg(MessageBody msg) { if (m_mySocket == null) { return; } if (!m_isSocketReady) { return; } m_sendMsgs.Enqueue(msg); }
public void PlayerReady() { CSReady proto = new CSReady(); byte[] bytes = ProtoSerialize.Serialize <CSReady>(proto); int size = bytes.Length; MessageBody body = new MessageBody(); body.size = (uint)(size + MessageBody.HEADER_TYPE_BYTES); body.type = (ushort)EMessageType.ECSReady; body.data = bytes; TCPClient.Instance.Send(body); }
void OnConnected() { CSLogin proto = new CSLogin(); byte[] bytes = ProtoSerialize.Serialize <CSLogin>(proto); int size = bytes.Length; MessageBody body = new MessageBody(); body.size = (uint)(size + MessageBody.HEADER_TYPE_BYTES); body.type = (ushort)EMessageType.ECSLogin; body.data = bytes; TCPClient.Instance.Send(body); }
private void HandleRecieveMsg() { lock ((m_recievedMsgs as System.Collections.ICollection).SyncRoot) { while (m_recievedMsgs.Count > 0) { MessageBody msg = m_recievedMsgs[0]; m_recievedMsgs.RemoveAt(0); if (msg != null) { OnMessageProc(msg); } } } }
void OnReady(params object[] args) { MessageBody body = args[0] as MessageBody; if (body == null) { return; } SCReady ret = ProtoSerialize.DeSerialize <SCReady>(body.data); if (ret == null) { DEBUG.Error("Invalid Proto"); return; } DEBUG.Log("OnReady"); }
void OnLogin(params object[] args) { MessageBody body = args[0] as MessageBody; if (body == null) { return; } SCLogin ret = ProtoSerialize.DeSerialize <SCLogin>(body.data); if (ret == null) { return; } Player instance = Instantiate <Player>(playerPrefab); instance.OnLogin(ret); }
void OnFrameTurn(params object[] args) { MessageBody body = args[0] as MessageBody; if (body == null) { return; } SCFrame proto = ProtoSerialize.DeSerialize <SCFrame>(body.data); if (proto == null) { DEBUG.Error("Invalid Proto"); return; } FrameInfo frameInfo = new FrameInfo(); frameInfo.CurFrameID = proto.FrameID; frameInfo.NxtFrameID = proto.NextFrameID; int size = proto.Users.Count; for (int i = 0; i < size; ++i) { UserFrame user = proto.Users[i]; List <EPlayerEvent> frameInfoPool = new List <EPlayerEvent>(); for (int j = 0; j < user.KeyInfo.Count; ++j) { System.UInt32 key = user.KeyInfo[j]; frameInfoPool.Add((EPlayerEvent)key); } frameInfo.UUID2FrameInfoPool.Add(user.UUID, frameInfoPool); } FrameTurn(frameInfo); CurFrameID = frameInfo.NxtFrameID; // DEBUG.Log("OnFrameTurn:: CurFrameID={0}, Size={1}", CurFrameID, body.size); }
void OnFrameInit(params object[] args) { MessageBody body = args[0] as MessageBody; if (body == null) { return; } SCFrameInit proto = ProtoSerialize.DeSerialize <SCFrameInit>(body.data); if (proto == null) { DEBUG.Error("Invalid Proto"); return; } CurFrameID = proto.CurFrameID; NxtFrameID = proto.NxtFrameID; DEBUG.Log("OnFrameInit:: CurFrameID={0} NxtFrameID={1}", CurFrameID, NxtFrameID); }
void SendKeyInfo() { CSFrame proto = new CSFrame(); proto.UUID = UUID; proto.FrameID = CurFrameID; for (int i = 0; i < CurFrameInfo.Count; ++i) { proto.KeyInfo.Add((System.UInt32)CurFrameInfo[i]); } CurFrameInfo.Clear(); byte[] bytes = ProtoSerialize.Serialize <CSFrame>(proto); int size = bytes.Length; MessageBody body = new MessageBody(); body.size = (uint)(size + MessageBody.HEADER_TYPE_BYTES); body.type = (ushort)EMessageType.ECSFrame; body.data = bytes; TCPClient.Instance.Send(body); }
public void Send(MessageBody body) { tcpClient.SendMsg(body); }