// Update is called once per frame void Update() { if (m_bReady) { LanSocket.MsgUnPack msg = null; m_GameNet.GetMsg(ref msg); if (null != msg) { print("here have one msg on client"); } if (Input.GetKeyUp(KeyCode.Space)) { LanSocket.MsgPack sendMsg = new LanSocket.MsgPack(); sendMsg.SetHead((int)NetMsgID.C2S_SELECT_ANIMAL); sendMsg.Pack16bit(1); sendMsg.PackEnd(); m_GameNet.Send(ref sendMsg); print("send 1"); } } else { m_GameServerIP = m_Reciver.GetIP(); if ("".Equals(m_GameServerIP)) { m_BroadTime -= Time.deltaTime; if (m_BroadTime - Time.deltaTime < 0.0f) { m_BroadTime = 5.0f; m_Sender.Send(); } } else { print("get broadcast ip:" + m_GameServerIP); GameStart(); } } }
public void GetMsg(ref MsgUnPack msg) { if (!m_HasInit) { return; } try { Lock(); if (0 != m_MsgNum) { ushort datalen = System.BitConverter.ToUInt16(m_AllData, m_AllDataHead); msg = new MsgUnPack(m_AllData, (ushort)m_AllDataHead, (ushort)datalen); m_AllDataHead += datalen; --m_MsgNum; } } finally { UnLock(); } }
void Action_S2C_SEND_ANIMAL_DATA(LanSocket.MsgUnPack msg) { }