void OnReceive(CmdPacket packet) { short cmd = 0; packet.ReadShort(ref cmd); string ret = ""; packet.ReadString(ref ret); Sys_Log(ret); }
int HandleSysPacket(CmdPacket packet) { short type = 0; uint param = 0; if (!packet.ReadShort(ref type)) { return(0); } switch (type) { case SYS_PACKET_KEEP_ALIVE: if (!packet.ReadUInt(ref param)) { return(0); } Sys_Log("recv keep alive msg"); m_sendCmdPkt.BeginWrite(); m_sendCmdPkt.WriteShort(SYS_PACKET_ALIVE_ACK); m_sendCmdPkt.WriteInt((int)param); SendPacket(m_sendCmdPkt, true, true); break; case SYS_PACKET_ALIVE_ACK: if (!packet.ReadUInt(ref param)) { return(0); } Sys_Log("recv alive ack msg"); m_rtt = Sys_GetTime() - param; break; case SYS_PACKET_SET_SEED: if (!packet.ReadUInt(ref param)) { return(0); } SetSeed(param); m_state = TNetState.NET_STATE_CONNECTED; OnConnect(true); break; default: return(0); } return(type); }