Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
 public static uint ToUInt(byte[] bytes)
 {
     lock (DefaultReader)
     {
         DefaultReader.Reset();
         DefaultReader._Write(bytes, 0, sizeof(uint));
         uint result = 0;
         DefaultReader.Out(out result);
         return(result);
     }
 }
 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);
 }