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); }
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); }
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); }
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); }
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); }