当前位置: 首页>>代码示例>>C#>>正文


C# IO.MessageHead类代码示例

本文整理汇总了C#中ZyGames.Framework.RPC.IO.MessageHead的典型用法代码示例。如果您正苦于以下问题:C# MessageHead类的具体用法?C# MessageHead怎么用?C# MessageHead使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageHead类属于ZyGames.Framework.RPC.IO命名空间,在下文中一共展示了MessageHead类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DecodePacket

 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     responsePack = ProtoBufUtils.Deserialize<Response1010Pack>(netReader.Buffer);
     string responseDataInfo = "";
     responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request1010Pack>(req) + "\n";
     responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Response1010Pack>(responsePack) + "\n";
     DecodePacketInfo = responseDataInfo;
     int childStepId = getChild(1010);
     System.Console.WriteLine("childStepID:" + childStepId);
     if (childStepId > 0)
     {
         System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
         /*
           req.UserID = GetParamsData("UserID", req.UserID);
         req.identify = GetParamsData("identify", req.identify);
         req.version = GetParamsData("version", req.version);
         req.the3rdUserID = GetParamsData("the3rdUserID", req.the3rdUserID);
         req.happyPoint = GetParamsData("happyPoint", req.happyPoint);
         req.Rate = GetParamsData("Rate", req.Rate);
         req.index = GetParamsData("index", req.index);
         req.strThe3rdUserID = GetParamsData("strThe3rdUserID", req.strThe3rdUserID);
         req.typeUser = GetParamsData("typeUser", req.typeUser);
          */
         dic.Add("UserID", req.UserID.ToString());
         dic.Add("index", responsePack.index.ToString());
         dic.Add("the3rdUserID", req.the3rdUserID.ToString());
         dic.Add("strThe3rdUserID", req.strThe3rdUserID);
        SetChildStep(childStepId.ToString(), _setting,dic);
     }
     return true;
 }
开发者ID:guccang,项目名称:autoTest,代码行数:31,代码来源:Step1010.cs

示例2: ResponseError

 public virtual void ResponseError(BaseGameResponse response, ActionGetter actionGetter, int errorCode, string errorInfo)
 {
     MessageHead head = new MessageHead(actionGetter.GetMsgId(), actionGetter.GetActionId(), errorCode, errorInfo);
     MessageStructure sb = new MessageStructure();
     sb.WriteBuffer(head);
     response.BinaryWrite(sb.PopBuffer());
 }
开发者ID:juneman,项目名称:Scut,代码行数:7,代码来源:ActionDispatcher.cs

示例3: SuccessCallback

 protected override void SuccessCallback(MessageStructure writer, MessageHead head)
 {
     int type = writer.ReadInt();
     if (type == 1)
     {
         int recordCount = writer.ReadInt();
         JsonObject jsonContainer = new JsonObject();
         List<JsonObject> jsonList = new List<JsonObject>();
         for (int i = 0; i < recordCount; i++)
         {
             writer.RecordStart();
             var item = new JsonObject();
             item.Add("NoticeID", writer.ReadString());
             item.Add("Title",  writer.ReadString());
             item.Add("Content", writer.ReadString());
             item.Add("IsBroadcast", writer.ReadInt());
             item.Add("IsTop", writer.ReadInt());
             item.Add("Creater", writer.ReadString());
             item.Add("CreateDate", writer.ReadString());
             item.Add("ExpiryDate", writer.ReadString());
             jsonList.Add(item);
             writer.RecordEnd();
         }
         jsonContainer.Add("total", recordCount);
         jsonContainer.Add("rows", jsonList.ToArray());
         WriteTableJson(jsonContainer);
     }
 }
开发者ID:0jpq0,项目名称:Scut,代码行数:28,代码来源:NoticeRemote.cs

示例4: OnReceiveTimeout

        public override void OnReceiveTimeout(string clientAddress, byte[] receiveData)
        {
            try
            {
                BufferReader reader = new BufferReader(receiveData);
                string paramString = reader.ReadPacketString();
                paramString = HttpUtility.UrlDecode(paramString, Encoding.UTF8);
                int index = paramString.IndexOf("?d=");
                if (index != -1)
                {
                    index += 3;
                    paramString = paramString.Substring(index, paramString.Length - index);
                }
                PacketMessage receivePacket = ParsePacketMessage(clientAddress, paramString, ConnectType.Tcp);
                var recHead = receivePacket.Head;

                int errorCode = LanguageHelper.GetLang().ErrorCode;
                string errorMsg = LanguageHelper.GetLang().RequestTimeout;
                MessageHead head = new MessageHead(recHead.MsgId, recHead.ActionId, "st", errorCode, errorMsg);
                head.HasGzip = true;
                MessageStructure ds = new MessageStructure();
                ds.WriteBuffer(head);
                byte[] data = ds.ReadBuffer();
                OnSendCompleted(clientAddress, data);
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("Send to client {0} timeout error:{1}", clientAddress, ex);
            }
        }
开发者ID:rongxiong,项目名称:Scut,代码行数:30,代码来源:ClientTransponder.cs

示例5: Create

        public static MessageStructure Create(string serverUrl, string requestParams, out MessageHead header, bool isSocket)
        {
            header = null;
            MessageStructure msgReader = null;
            if (isSocket)
            {
                msgReader = DoRequest(serverUrl, requestParams);
            }
            else
            {
                Encoding encode = Encoding.GetEncoding("utf-8");
                string postData = "d=" + GetSign(requestParams);
                byte[] bufferData = encode.GetBytes(postData);

                HttpWebRequest serverRequest = (HttpWebRequest)WebRequest.Create(serverUrl);
                serverRequest.Method = "POST";
                serverRequest.ContentType = "application/x-www-form-urlencoded";
                serverRequest.ContentLength = bufferData.Length;
                Stream requestStream = serverRequest.GetRequestStream();
                requestStream.Write(bufferData, 0, bufferData.Length);
                requestStream.Close();
                //������
                WebResponse serverResponse = serverRequest.GetResponse();
                Stream responseStream = serverResponse.GetResponseStream();
                msgReader = MessageStructure.Create(responseStream, Encoding.UTF8);
            }
            if (msgReader != null)
            {
                header = msgReader.ReadHeadGzip();
            }
            return msgReader;
        }
开发者ID:huyanoperation,项目名称:Scut,代码行数:32,代码来源:NetHelper.cs

示例6: CtorErrMsg

 public static byte[] CtorErrMsg(int error, string msg, NameValueCollection requestParam)
 {
     int msgId = Convert.ToInt32(requestParam["msgid"]);
     int actionid = Convert.ToInt32(requestParam["actionid"]);
     var ms = new MessageStructure();
     var head = new MessageHead(msgId, actionid, "st", error, msg);
     ms.WriteBuffer(head);
     return ms.PosGzipBuffer();
 }
开发者ID:87170360,项目名称:Maximus,代码行数:9,代码来源:RequestParse.cs

示例7: DecodePacket

 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     responsePack = ProtoBufUtils.Deserialize<Response1003Pack>(netReader.Buffer);
     string responseDataInfo = "";
     responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request1003Pack>(req) + "\n";
     responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Response1003Pack>(responsePack) + "\n";
     DecodePacketInfo = responseDataInfo;
     return true;
 }
开发者ID:guccang,项目名称:autoTest,代码行数:9,代码来源:Step1003.cs

示例8: DecodePacket

 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     _session.Context.SessionId = reader.ReadString();
     _session.Context.UserId = reader.ReadString().ToInt();
     int UserType = reader.ReadInt();
     string LoginTime = reader.ReadString();
     int GuideID = reader.ReadInt();
     if (GuideID == 1005)
     {
         SetChildStep("1005");
     }
     return true;
 }
开发者ID:GamesDesignArt,项目名称:UniversalCommon,代码行数:13,代码来源:Step1004.cs

示例9: DecodePacket

 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     responsePack = ProtoBufUtils.Deserialize<ResponsePack>(netReader.Buffer);
      string responseDataInfo = "";
      responseDataInfo  = "request :" + Game.Utils.JsonHelper.prettyJson<Request1000Pack>(req) + "\n";
      responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<ResponsePack>(responsePack) + "\n";
      DecodePacketInfo = responseDataInfo;
      int childStepId = getChild(1000);
      if(childStepId>0)
      {
         System.Collections.Generic.Dictionary<string,string> dic = new System.Collections.Generic.Dictionary<string,string>();
         dic.Add("UserID",responsePack.UserID.ToString()) ;
         SetChildStep(childStepId.ToString(),_setting,dic);
      }
      return true;
 }
开发者ID:guccang,项目名称:autoTest,代码行数:16,代码来源:Step1000.cs

示例10: DecodePacket

        protected override bool DecodePacket(MessageStructure reader, MessageHead head)
        {
            try
            {
                responsePack = ProtoBufUtils.Deserialize<Action3000Response>(netReader.Buffer);
                string responseDataInfo = "";
                responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Action3000Request>(req) + "\n";
                responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<Action3000Response>(responsePack) + "\n";
                DecodePacketInfo = responseDataInfo;
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.Message);
            }

            return true;
        }
开发者ID:guccang,项目名称:autoTest,代码行数:17,代码来源:Step3000.cs

示例11: RequestTimeout

        public void RequestTimeout(HttpConnection connection)
        {
            var param = connection.Param;
            int msgId = param.Get("MsgId").ToInt();
            int actionId = param.Get("ActionId").ToInt();
            int errorCode = LanguageHelper.GetLang().ErrorCode;
            string errorMsg = LanguageHelper.GetLang().RequestTimeout;
            var head = new MessageHead(msgId, actionId, "st", errorCode, errorMsg);
            head.HasGzip = true;
            var ms = new MessageStructure();
            ms.WriteBuffer(head);
            byte[] data = ms.ReadBuffer();

            string remoteAddress = connection.Context.Request.RemoteEndPoint.Address.ToString();
            string successMsg = string.Format("{0}>>发送超时到{1} {2}字节!",
                                              DateTime.Now.ToString("HH:mm:ss:ms"), remoteAddress, data.Length);
            Console.WriteLine(successMsg);
            OnResponseCompleted(connection, data);
        }
开发者ID:rongxiong,项目名称:Scut,代码行数:19,代码来源:HttpTransponder.cs

示例12: DecodePacket

 protected override bool DecodePacket(MessageStructure reader, MessageHead head)
 {
     responsePack = ProtoBufUtils.Deserialize<ResponsePack>(netReader.Buffer);
     string responseDataInfo = "";
     responseDataInfo = "request :" + Game.Utils.JsonHelper.prettyJson<Request2000Pack>(req) + "\n";
     responseDataInfo += "response:" + Game.Utils.JsonHelper.prettyJson<ResponsePack>(responsePack) + "\n";
     DecodePacketInfo = responseDataInfo;
     int childStepId = getChild(2000);
     System.Console.WriteLine("childStepID:"+childStepId);
     if (childStepId > 0)
     {
         System.Collections.Generic.Dictionary<string, string> dic = new System.Collections.Generic.Dictionary<string, string>();
         /*
            req.token = GetParamsData("token",req.token);
                   req.typeUser = GetParamsData("typeUser",req.typeUser);
                   req.version = GetParamsData("version", req.version);
                   req.UserID = GetParamsData("UserID", req.UserID);
          */
         SetChildStep(childStepId.ToString(),_setting,dic);
     }
     return true;
 }
开发者ID:guccang,项目名称:autoTest,代码行数:22,代码来源:Step2000.cs

示例13: WriteBuffer

 /// <summary>
 /// 将缓冲队列写入缓冲区,大于10k开始压缩
 /// </summary>
 /// <param name="head"></param>
 public void WriteBuffer(MessageHead head)
 {
     int stackSize = GetHeadByteSize(head);
     stackSize += GetStackByteSize();//包括了头部长度大小
     head.TotalLength = stackSize;
     bool hasGzipHead = false;
     if (head.HasGzip && (!EnableGzip || (EnableGzip && stackSize <= EnableGzipMinByte)))
     {
         hasGzipHead = true;
         head.GzipLength = stackSize;
         WriteByte(head.GzipLength);
     }
     //输出总字节长度,公式: stackSize = len(头) + len(内容) + 4(int)
     WriteByte(stackSize);
     WriteHeadBufer(head);
     WriteStackToBuffer();
     //判断是否有启用Gzip
     if (head.HasGzip && EnableGzip && !hasGzipHead && stackSize > EnableGzipMinByte)
     {
         byte[] orgData = PopBuffer();
         head.GzipLength = WriteGzipCompressBuffer(orgData);
     }
     head.PacketLength = Length;
     Reset();
 }
开发者ID:yunjoker,项目名称:Scut,代码行数:29,代码来源:MessageStructure.cs

示例14: ReadHeadGzip

 /// <summary>
 /// 读取消息头,如果有Gzip压缩时自动解压字节流
 /// </summary>
 /// <returns></returns>
 /// <exception cref="OverflowException"></exception>
 public MessageHead ReadHeadGzip()
 {
     try
     {
         MessageHead head = new MessageHead();
         head.HasGzip = true;
         head.PacketLength = Length;
         if (CheckGzipBuffer())
         {
             byte[] gzipData = PopBuffer();
             head.GzipLength = gzipData.Length;
             //gzip格式500+gzip( 1000+ XXXXXX)
             byte[] deZipData = GzipUtils.DeCompress(gzipData, 0, gzipData.Length);
             WriteByte(deZipData);
             Reset();
         }
         head.TotalLength = ReadInt();
         head.ErrorCode = ReadInt();
         head.MsgId = ReadInt();
         head.ErrorInfo = ReadString();
         head.Action = ReadInt();
         head.St = ReadString();
         return head;
     }
     catch (Exception ex)
     {
         string error = string.Format("read to {0}/{1}pos error,\r\nbytes:{2}", Offset, Length, ToHexString());
         throw new OverflowException(error, ex);
     }
 }
开发者ID:yunjoker,项目名称:Scut,代码行数:35,代码来源:MessageStructure.cs

示例15: ReadHead

 /// <summary>
 /// 读取消息头
 /// </summary>
 /// <returns></returns>
 public MessageHead ReadHead()
 {
     MessageHead head = new MessageHead();
     head.PacketLength = Length;
     head.TotalLength = ReadInt();
     head.ErrorCode = ReadInt();
     head.MsgId = ReadInt();
     head.ErrorInfo = ReadString();
     head.Action = ReadInt();
     head.St = ReadString();
     return head;
 }
开发者ID:yunjoker,项目名称:Scut,代码行数:16,代码来源:MessageStructure.cs


注:本文中的ZyGames.Framework.RPC.IO.MessageHead类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。