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


C# MessageStructure.ReadBuffer方法代码示例

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


在下文中一共展示了MessageStructure.ReadBuffer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

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

示例3: OnNetTcpCallback

 private static void OnNetTcpCallback(object sender, RemoteEventArgs e)
 {
     try
     {
         RemoteService proxy = sender as RemoteService;
         if (proxy == null)
         {
             return;
         }
         try
         {
             using (var ms = new MessageStructure(e.Data))
             {
                 var head = ms.ReadHeadGzip();
                 if (head != null)
                 {
                     var package = proxy.Find(head.MsgId);
                     if (package != null)
                     {
                         package.Message = ms.ReadBuffer();
                         proxy.Remove(head.MsgId);
                         package.OnCallback();
                         return;
                     }
                 }
             }
         }
         catch (Exception)
         { }
         proxy.OnPushedHandle(e);
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("OnNetTcpCallback error:{0}", ex);
     }
 }
开发者ID:yunjoker,项目名称:Scut,代码行数:36,代码来源:RemoteService.cs

示例4: Receive


//.........这里部分代码省略.........

            #endif
            var settings = ParseRequestSettings(paramGeter, remoteAddress);
            settings.ParamString = paramString;
            settings.RouteName = routeName;

            byte[] sendBuffer = new byte[0];
            RequestError error = RequestError.Success;
            try
            {
                if (isRoute)
                {
                    if (CheckCallAccessLimit(remoteAddress))
                    {
                        error = RequestError.Unknown;
                        head.ErrorInfo = ErrorCallAccessLimit;
                    }
                    else
                    {
                        ServiceRequest.CallRemote(settings, out sendBuffer);
                    }
                }
                else
                {
                    ServiceRequest.Request(settings, out sendBuffer);
                }
            }
            catch (CommunicationObjectFaultedException fault)
            {
                TraceLog.WriteError("The wcfclient request faulted:{0}", fault);
                error = RequestError.Closed;
                ServiceRequest.ResetChannel(settings);
            }
            catch (Exception ex)
            {
                if (ex.InnerException is SocketException)
                {
                    var sex = ex.InnerException as SocketException;
                    TraceLog.WriteError("The wcfclient request connect:{0}-{1}", sex.SocketErrorCode, sex);
                    if (sex.SocketErrorCode == SocketError.TimedOut)
                    {
                        error = RequestError.Timeout;
                    }
                    else
                    {
                        error = RequestError.UnableConnect;
                    }
                }
                else
                {
                    TraceLog.WriteError("The wcfclient request error:{0}", ex);
                    error = RequestError.Unknown;
                }
                ServiceRequest.ResetChannel(settings);
            }
            watch.Stop();
            switch (error)
            {
                case RequestError.Success:
                    ms.WriteGzipBuffer(sendBuffer);

                    string msg = string.Format("[{0}]请求响应{1}:route={8},MsgId={2},St={3},Action-{4},error:{5}-{6},bytes:{7},响应时间:{9}ms\r\n",
                                               DateTime.Now.ToLongTimeString(),
                                               session.RemoteAddress,
                                               head.MsgId,
                                               head.St,
                                               head.Action,
                                               head.ErrorCode,
                                               head.ErrorInfo,
                                               sendBuffer.Length,
                                               routeName,
                                               (int)watch.Elapsed.TotalMilliseconds);
                    TraceLog.ReleaseWrite(msg);
            #if DEBUG
            #endif
                    Console.WriteLine(msg);

                    break;
                case RequestError.Closed:
                case RequestError.NotFindService:
                    head.ErrorInfo = ErrorNotFind;
                    DoWriteError(ms, head);
                    break;
                case RequestError.UnableConnect:
                    head.ErrorInfo = ErrorConnected;
                    DoWriteError(ms, head);
                    break;
                case RequestError.Timeout:
                    head.ErrorInfo = ErrorTimeout;
                    DoWriteError(ms, head);
                    break;
                case RequestError.Unknown:
                    DoWriteError(ms, head);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("RequestError", error, "Not process RequestError enum.");
            }
            sendBuffer = ms.ReadBuffer();
            return sendBuffer;
        }
开发者ID:rongxiong,项目名称:Scut,代码行数:101,代码来源:TcpSocketReceiver.cs

示例5: OnCallRemoteComplated

 protected byte[] OnCallRemoteComplated(ChannelContext context, string route, string param, string remoteAddress)
 {
     lock (context)
     {
         HttpGet httpGet = new HttpGet(param, remoteAddress);
         MessageStructure structure = new MessageStructure();
         MessageHead head = new MessageHead();
         OnCallRemote(route, httpGet, head, structure);
         structure.WriteBuffer(head);
         return structure.ReadBuffer();
     }
 }
开发者ID:rongxiong,项目名称:Scut,代码行数:12,代码来源:GameHost.cs

示例6: OnSendToClient

 protected virtual void OnSendToClient(PacketMessage packet)
 {
     var clientAddress = packet.Head.Address;
     byte[] content = packet.Content;
     if (!packet.Head.EnableGzip)
     {
         //gzip压缩包
         MessageStructure ds = new MessageStructure();
         ds.WriteGzipBuffer(content);
         packet.Content = ds.ReadBuffer();
     }
     byte[] data = packet.Content;
     OnSendCompleted(clientAddress, data);
 }
开发者ID:rongxiong,项目名称:Scut,代码行数:14,代码来源:ClientTransponder.cs

示例7: RequestError

 /// <summary>
 /// 出错处理
 /// </summary>
 /// <param name="response"></param>
 /// <param name="actionID"></param>
 /// <param name="errorCode"></param>
 /// <param name="errorInfo"></param>
 public static void RequestError(IGameResponse response, int actionID, int errorCode, string errorInfo)
 {
     MessageHead head = new MessageHead(actionID, errorCode, errorInfo);
     MessageStructure sb = new MessageStructure();
     sb.WriteBuffer(head);
     response.BinaryWrite(sb.ReadBuffer());
 }
开发者ID:0jpq0,项目名称:Scut,代码行数:14,代码来源:ActionFactory.cs

示例8: DoSerialize

        private static byte[] DoSerialize(params BaseEntity[] entityList)
        {
            var rootWriter = new MessageStructure();
            rootWriter.PushIntoStack(entityList.Length);
            object fieldValue = null;
            foreach (var entity in entityList)
            {
                var schema = entity.GetSchema();
                if (schema == null)
                {
                    continue;
                }
                var recordWriter = new MessageStructure();
                recordWriter.PushIntoStack(schema.Name);
                //write columns
                var columns = schema.GetColumns();
                foreach (var column in columns)
                {
                    fieldValue = entity.GetPropertyValue(column.Name);
                    if (EntitySchemaSet.IsSupportType(column.ColumnType))
                    {
                        recordWriter.PushIntoStack(column.ColumnType, fieldValue);
                    }
                    else if (column.HasChild)
                    {
                        PushChildStack(recordWriter, column, fieldValue);
                    }
                }

                rootWriter.PushIntoStack(recordWriter);
            }

            var head = new MessageHead(SyncActionId);
            rootWriter.WriteBuffer(head);
            return rootWriter.ReadBuffer();
        }
开发者ID:haiya,项目名称:Scut,代码行数:36,代码来源:EntitySyncManger.cs


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