• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IO.MessageStructure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例3: 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


示例4: 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


示例5: ProcessRequest

        /// <summary>
        /// 
        /// </summary>
        /// <param name="package"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public byte[] ProcessRequest(object package, object param)
        {
            var httpresponse = new SocketGameResponse();
            ActionGetter actionGetter = null;
            try
            {
                httpresponse.WriteErrorCallback += new ScutActionDispatcher().ResponseError;

                RequestPackage p = package as RequestPackage;
                actionGetter = param as ActionGetter;

                if (!string.IsNullOrEmpty(p.RouteName))
                {
                    if (CheckRemote(p.RouteName, actionGetter))
                    {
                        MessageStructure response = new MessageStructure();
                        OnCallRemote(p.RouteName, actionGetter, response);
                        return response.PopBuffer();
                    }
                    httpresponse.WriteError(actionGetter, 10000, "No permission");
                }
                else
                {
                    DoAction(actionGetter, httpresponse);
                }
                return httpresponse.ReadByte();
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("Request error:{0}", ex);
                MessageStructure response = new MessageStructure();
                response.WriteBuffer(new MessageHead(0, 10000, "request error"));
                return response.PopBuffer();
            }
        }
开发者ID:yunjoker,项目名称:Scut,代码行数:41,代码来源:GameBaseHost.cs


示例6: HttpServiceRequest

 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public HttpServiceRequest(HttpContext context)
 {
     _buffer = new MessageStructure();
     httpGet = new HttpGet(context.Request);
     response = new HttpGameResponse(context.Response);
     ParamString = httpGet.ParamString;
     SessionId = httpGet.SessionId;
 }
开发者ID:rongxiong,项目名称:Scut,代码行数:12,代码来源:HttpServiceRequest.cs


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: BuildLuaFile

        public static string BuildLuaFile(List<ParamInfoModel> paramList, MessageStructure msgReader, string[] keyNames)
        {
            var respParams = paramList.Where(p => p.ParamType == 2).OrderBy(p => p.SortID);
            StringBuilder containerBuilder = new StringBuilder();
            int loopDepth = 0;//循环深度
            List<ParamInfoModel> recordQueue = new List<ParamInfoModel>();
            foreach (var record in respParams)
            {
                string fieldName = record.Field;
                FieldType fieldType = record.FieldType;
                string fieldValue = "";

                if (loopDepth > 0 && fieldType == FieldType.End)
                {
                    loopDepth--;
                    recordQueue.Add(record);
                }
                if (loopDepth == 0 && recordQueue.Count > 0)
                {
                    //处理循环记录
                    ParseRecordEnd(containerBuilder, msgReader, recordQueue, loopDepth, 0, keyNames);
                    recordQueue.Clear();
                }

                if (loopDepth == 0)
                {
                    if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
                    {
                        //自动登录
                    }
                    if (fieldType == FieldType.Record)
                    {
                        loopDepth++;
                        recordQueue.Add(record);
                    }
                }
                else if (fieldType != FieldType.End)
                {
                    if (fieldType == FieldType.Record)
                    {
                        loopDepth++;
                    }
                    recordQueue.Add(record);
                }
            }
            return containerBuilder.ToString();
        }
开发者ID:87170360,项目名称:Maximus,代码行数:47,代码来源:ClientConfigInfo.aspx.cs


示例12: BuildLuaFile

        public static string BuildLuaFile(DataTable table, MessageStructure msgReader, string[] keyNames)
        {
            StringBuilder containerBuilder = new StringBuilder();
            int loopDepth = 0;//ѭ�����
            List<DataRow> recordQueue = new List<DataRow>();
            foreach (DataRow record in table.Rows)
            {
                string fieldName = record["Field"].ToString();
                FieldType fieldType = (FieldType)Enum.Parse(typeof(FieldType), record["FieldType"].ToString());
                string fieldValue = "";

                if (loopDepth > 0 && fieldType == FieldType.End)
                {
                    loopDepth--;
                    recordQueue.Add(record);
                }
                if (loopDepth == 0 && recordQueue.Count > 0)
                {
                    //����ѭ����¼
                    ParseRecordEnd(containerBuilder, msgReader, recordQueue, loopDepth, 0, keyNames);
                    recordQueue.Clear();
                }

                if (loopDepth == 0)
                {
                    if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
                    {
                        //�Զ���¼
                    }
                    if (fieldType == FieldType.Record)
                    {
                        loopDepth++;
                        recordQueue.Add(record);
                    }
                }
                else if (fieldType != FieldType.End)
                {
                    if (fieldType == FieldType.Record)
                    {
                        loopDepth++;
                    }
                    recordQueue.Add(record);
                }
            }
            return containerBuilder.ToString();
        }
开发者ID:houguohua,项目名称:Scut,代码行数:46,代码来源:LuaScriptHelper.cs


示例13: 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


示例14: 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


示例15: 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


示例16: GetFieldValue

        public static bool GetFieldValue(MessageStructure ms, FieldType fieldType, ref string val)
        {
            bool result = false;
            switch (fieldType)
            {
                case FieldType.Int:
                    val = ms.ReadInt().ToString();
                    result = true;
                    break;
                case FieldType.String:
                    val = ms.ReadString();
                    result = true;
                    break;
                case FieldType.Short:
                    val = ms.ReadShort().ToString();
                    result = true;
                    break;
                case FieldType.Byte:
                    val = ms.ReadByte().ToString();
                    result = true;
                    break;
                case FieldType.Long:
                    val = ms.ReadLong().ToString();
                    result = true;
                    break;
                case FieldType.Bool:
                    val = ms.ReadBool().ToString();
                    result = true;
                    break;
                case FieldType.Float:
                    val = ms.ReadFloat().ToString();
                    result = true;
                    break;
                case FieldType.Double:
                    val = ms.ReadDouble().ToString();
                    result = true;
                    break;
                case FieldType.Record:
                    break;
                case FieldType.End:
                    break;
                case FieldType.Head:
                    break;
                default:
                    break;
            }

            return result;
        }
开发者ID:huyanoperation,项目名称:Scut,代码行数:49,代码来源:NetHelper.cs


示例17: OnCallRemote

 /// <summary>
 /// Call remote method
 /// </summary>
 /// <param name="routePath"></param>
 /// <param name="actionGetter"></param>
 /// <param name="response"></param>
 protected virtual void OnCallRemote(string routePath, ActionGetter actionGetter, MessageStructure response)
 {
     try
     {
         string[] mapList = routePath.Split('.');
         string funcName = "";
         string routeName = routePath;
         if (mapList.Length > 1)
         {
             funcName = mapList[mapList.Length - 1];
             routeName = string.Join("/", mapList, 0, mapList.Length - 1);
         }
         string routeFile = "";
         int actionId = actionGetter.GetActionId();
         MessageHead head = new MessageHead(actionId);
         if (!ScriptEngines.SettupInfo.DisablePython)
         {
             routeFile = string.Format("Remote.{0}", routeName);
             dynamic scope = ScriptEngines.ExecutePython(routeFile);
             if (scope != null)
             {
                 var funcHandle = scope.GetVariable<RemoteHandle>(funcName);
                 if (funcHandle != null)
                 {
                     funcHandle(actionGetter, head, response);
                     response.WriteBuffer(head);
                     return;
                 }
             }
         }
         string typeName = string.Format(GameEnvironment.Setting.RemoteTypeName, routeName);
         routeFile = string.Format("Remote.{0}", routeName);
         var args = new object[] { actionGetter, response };
         var instance = (object)ScriptEngines.Execute(routeFile, typeName, args);
         if (instance is RemoteStruct)
         {
             var target = instance as RemoteStruct;
             target.DoRemote();
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("OnCallRemote error:{0}", ex);
     }
 }
开发者ID:yunjoker,项目名称:Scut,代码行数:51,代码来源:GameBaseHost.cs


示例18: SocketGameResponse

 /// <summary>
 /// 
 /// </summary>
 public SocketGameResponse()
 {
     _buffers = new MessageStructure();
 }
开发者ID:houguohua,项目名称:Scut,代码行数:7,代码来源:SocketGameResponse.cs


示例19: OnCallRemote

 //protected override void DoListen()
 //{
 //    this.ServiceProxy.Listen(9001);
 //}
 protected override void OnCallRemote(string route, HttpGet httpGet, MessageHead head, MessageStructure structure)
 {
 }
开发者ID:rongxiong,项目名称:Scut,代码行数:7,代码来源:GameHostApp.cs


示例20: ParseRecordEnd

        private static void ParseRecordEnd(StringBuilder itemBuilder, MessageStructure msgReader, List<ParamInfoModel> queue, int depth, int recordNum, string[] keyNames)
        {
            string keyValue = string.Empty;
            string keyName = keyNames.Length > depth ? keyNames[depth] : string.Empty;
            List<LuaConfig> builderList = new List<LuaConfig>();
            int recordCount = 0;
            try
            {
                recordCount = msgReader.ReadInt();
            }
            catch { }
            for (int i = 0; i < recordCount; i++)
            {
                try
                {
                    msgReader.RecordStart();
                    int loopDepth = 0; //循环深度
                    StringBuilder recordBuilder = new StringBuilder();
                    List<ParamInfoModel> recordQueue = new List<ParamInfoModel>();

                    int columnNum = 0;
                    int childNum = 0;

                    #region 遍历列取数据
                    for (int r = 1; r < queue.Count - 1; r++)
                    {
                        var record = queue[r];
                        string fieldName = record.Field;
                        FieldType fieldType = record.FieldType;
                        string fieldValue = "";
                        try
                        {
                            if (loopDepth > 0 && fieldType == FieldType.End)
                            {
                                loopDepth--;
                                recordQueue.Add(record);
                            }
                            if (loopDepth == 0 && recordQueue.Count > 0)
                            {
                                //处理循环记录
                                childNum++;
                                var childBuilder = new StringBuilder();
                                ParseRecordEnd(childBuilder, msgReader, recordQueue, depth + 1, childNum, keyNames);
                                //
                                recordQueue.Clear();
                                //选择输出格式
                                FormatChildToLua(recordBuilder, childBuilder, columnNum);
                            }

                            if (loopDepth == 0)
                            {
                                if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
                                {
                                    if (columnNum > 0)
                                    {
                                        recordBuilder.Append(",");
                                    }
                                    if (fieldName.Trim().ToLower() == keyName.Trim().ToLower())
                                    {
                                        keyValue = fieldValue;
                                    }
                                    if (fieldType == FieldType.Byte || fieldType == FieldType.Short || fieldType == FieldType.Int)
                                    {
                                        recordBuilder.AppendFormat("{0}={1}", fieldName, fieldValue);
                                    }
                                    else
                                    {
                                        recordBuilder.AppendFormat("{0}=\"{1}\"", fieldName, fieldValue);
                                    }
                                    columnNum++;
                                }
                                if (fieldType == FieldType.Record)
                                {
                                    loopDepth++;
                                    recordQueue.Add(record);
                                }
                            }
                            else if (fieldType != FieldType.End)
                            {
                                if (fieldType == FieldType.Record)
                                {
                                    loopDepth++;
                                }
                                recordQueue.Add(record);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("recordindex:{0},fieldName:{1} error:", i, fieldName), ex);
                        }
                    }

                    #endregion
                    //读取行结束
                    msgReader.RecordEnd();
                    builderList.Add(new LuaConfig { Key = keyValue, Builder = recordBuilder });
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("recordindex:{0}error:", i), ex);
//.........这里部分代码省略.........
开发者ID:87170360,项目名称:Maximus,代码行数:101,代码来源:ClientConfigInfo.aspx.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Sockets.ConnectionEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# IO.MessageHead类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap