Esempio n. 1
0
        public void ConstructMessage(ActionGetter actionGetter, IMessageData message)
        {
            LCPacketHead packetHead = new LCPacketHead()
            {
                MsgId     = actionGetter.GetMsgId(),
                ActionId  = actionGetter.GetActionId(),
                ErrorCode = 0,
                ErrorInfo = string.Empty
            };

            byte[] headBytes = ProtoBufUtils.Serialize(packetHead);
            byte[] data      = ProtoBufUtils.Serialize(message);
            m_Message = BufferUtils.MergeBytes(BufferUtils.AppendHeadBytes(headBytes), data);
        }
Esempio n. 2
0
        public static byte[] GeneratePackageStream(int actionId, byte[] data)
        {
            LCPacketHead packetHead = new LCPacketHead()
            {
                MsgId     = 0,
                ActionId  = actionId,
                ErrorCode = 0,
                ErrorInfo = string.Empty
            };

            byte[] headBytes = ProtoBufUtils.Serialize(packetHead);
            byte[] buffer    = BufferUtils.MergeBytes(BufferUtils.AppendHeadBytes(headBytes), data);
            return(buffer);
        }
Esempio n. 3
0
        public static void PushError(int actionId, GameSession session, int errorCode, string errorInfo)
        {
            LCPacketHead packetHead = new LCPacketHead()
            {
                MsgId     = 0,
                ActionId  = actionId,
                ErrorCode = errorCode,
                ErrorInfo = errorInfo
            };

            byte[] headBytes = ProtoBufUtils.Serialize(packetHead);
            byte[] buffer    = BufferUtils.AppendHeadBytes(headBytes);
            session.SendAsync(buffer, 0, buffer.Length);
        }
Esempio n. 4
0
        public void ResponseError(BaseGameResponse response, ActionGetter actionGetter, int errorCode, string errorInfo)
        {
            LCPacketHead packetHead = new LCPacketHead()
            {
                MsgId     = actionGetter.GetMsgId(),
                ActionId  = actionGetter.GetActionId(),
                ErrorCode = errorCode,
                ErrorInfo = errorInfo
            };

            byte[] headBytes = ProtoBufUtils.Serialize(packetHead);
            byte[] buffer    = BufferUtils.AppendHeadBytes(headBytes);
            response.BinaryWrite(buffer);
        }
Esempio n. 5
0
        public static void ResponseOK(BaseGameResponse response, ActionGetter actionGetter, byte[] data)
        {
            LCPacketHead packetHead = new LCPacketHead()
            {
                MsgId     = actionGetter.GetMsgId(),
                ActionId  = actionGetter.GetActionId(),
                ErrorCode = 0,
                ErrorInfo = string.Empty
            };

            byte[] headBytes = ProtoBufUtils.Serialize(packetHead);
            byte[] buffer    = BufferUtils.MergeBytes(BufferUtils.AppendHeadBytes(headBytes), data);
            //response.BinaryWrite(buffer);
            actionGetter.GetSession().SendAsync(buffer, 0, buffer.Length);
        }