Esempio n. 1
0
        public override void WriteResponse(BaseGameResponse response)
        {
            SetResponseHead();
            byte[] headBytes    = ProtoBufUtils.Serialize(_responseHead);
            byte[] contentBytes = BuildResponsePack();
            byte[] buffer       = null;
            if (contentBytes == null || contentBytes.Length == 0)
            {
                buffer = BufferUtils.AppendHeadBytes(headBytes);
            }
            else
            {
                if (actionId != 2502 &&
                    actionId != 4000)
                {
                    buffer = BufferUtils.MergeBytes(
                        BufferUtils.AppendHeadBytes(headBytes),
                        contentBytes
                        );
                }
                else
                {
                    buffer = BufferUtils.GetBytes(contentBytes);
                }
            }
            //需要对字节数据加密处理,这里跳过

            response.BinaryWrite(buffer);
        }
Esempio n. 2
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. 3
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. 4
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. 5
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. 6
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);
        }
        public void ResponseError(BaseGameResponse response, ActionGetter actionGetter, int errorCode, string errorInfo)
        {
            //实现出错处理下发
            ResponsePack head = new ResponsePack()
            {
                MsgId     = actionGetter.GetMsgId(),
                ActionId  = actionGetter.GetActionId(),
                ErrorCode = errorCode,
                ErrorInfo = errorInfo,
                St        = actionGetter.GetSt()
            };

            byte[] headBytes = ProtoBufUtils.Serialize(head);
            byte[] buffer    = BufferUtils.AppendHeadBytes(headBytes);
            response.BinaryWrite(buffer);
        }