public static byte[] ToBytes(uint value) { lock (DefaultWriter) { DefaultWriter.Reset(); DefaultWriter.In(value); byte[] bytes = new byte[DefaultWriter.Size]; DefaultWriter._Read(bytes, DefaultWriter.Size); return(bytes); } }
public void OnReceive(ISession session, byte[] bytes, int len) { NetMessage msg = new NetMessage(); m_RecvBuff.Reset(); m_RecvBuff.In(bytes, 0, (uint)len); msg.Unpack(m_RecvBuff); if (session.IsAuth()) { if (msg.head.cmd == 0) { msg.ReadMsg(ref RPCMessage.Default); HandleRPCMessage(session, RPCMessage.Default); } else { HandlePBMessage(session, msg); } } else { if (msg.head.cmd == m_authCmd) { HandlePBMessage(session, msg); } else { Debuger.LogWarning("收到未鉴权的消息! cmd:{0}", msg.head.cmd); } } }
private void OnReceive(byte[] bytes, int len) { m_RecvBuff.Reset(); m_RecvBuff.In(bytes, 0, (uint)len); NetMessage msg = new NetMessage(); msg.Unpack(m_RecvBuff); Debuger.LogError("OnReceive! uid:{0}", msg.head.uid); if (msg.head.cmd == 0) { msg.ReadMsg(ref RPCMessage.Default); HandleRPCMessage(RPCMessage.Default); } else { HandlePBMessage(msg); } }
public static object DecodeProtoMsg(this SmartBuffer buff, byte[] bytes, object msg, Type type) { buff.Reset(); buff.In(bytes, 0, (uint)bytes.Length); return(Serializer.Merge(buff, msg, type)); }
public static void DecodeProtoMsg <T>(this SmartBuffer buff, byte[] bytes, T msg) { buff.Reset(); buff.In(bytes, 0, (uint)bytes.Length); Serializer.Merge(buff, msg); }