Example #1
0
 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);
     }
 }
Example #2
0
 private static void OnReceive(object sender, SocketEventArgs e)
 {
     var myConnect = ((ClientSocket)sender).UserData as MyConnect;
     if (myConnect != null)
     {
         var stream = new MessageStructure(e.Data);
         var head = stream.ReadHeadGzip();
         var pack = new MyPack() { Head = head, Data = e.Data };
         myConnect.actionPools.Enqueue(pack);
     }
 }
Example #3
0
 private void DoReceive(byte[] data)
 {
     try
     {
         MessageStructure writer = new MessageStructure(data);
         var head = writer.ReadHeadGzip();
         if (head.Success)
         {
             SuccessCallback(writer, head);
         }
         else
         {
             FailCallback(head);
         }
     }
     catch (Exception ex)
     {
         new BaseLog().SaveLog(ex);
     }
 }
Example #4
0
        private void DoRunProcess(byte[] sendData)
        {
            bool success = false;
            try
            {
                MessageStructure reader = null;
                MessageHead head = null;
                _stepTimer.StartTime();
                _session.Proxy.SendAsync(sendData, data =>
                {
                    try
                    {
                        if (data.Length == 0) return true;
                        reader = new MessageStructure(data);
                        head = reader.ReadHeadGzip();
                        return head.Action.ToString() == Action;
                    }
                    catch (Exception ex)
                    {
                        TraceLog.WriteError("Step {0} error:{1}", Action, ex);
                        return false;
                    }
                });

                if (CheckCompleted(head) && DecodePacket(reader, head))
                {
                    success = true;
                    _stepTimer.Completed();
                }
            }
            catch (Exception ex)
            {
                _stepTimer.PushError(ex.Message);
            }
            finally
            {
                _stepTimer.StopTime();
            }

            if (success && ChildStep != null)
            {
                ChildStep.StartRun();
            }
        }