예제 #1
0
        private void DoRunProcess(byte[] sendData)
        {
            bool readerSuccess = false;
            bool success       = false;

            try
            {
                MessageStructure reader = null;
                MessageHead      head   = null;
                _stepTimer.StartTime();
                //Console.WriteLine("DoRunProcess:"+ indentify);
                _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 (netReader.pushNetStream(data))
                    {
                        readerSuccess = true;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });

                if (CheckCompleted(head) && readerSuccess && DecodePacket(reader, head))
                {
                    success = true;
                    _stepTimer.Completed();
                }
                else
                {
                    Console.WriteLine(indentify + " acction error");
                }
            }
            catch (Exception ex)
            {
                _stepTimer.PushError(ex.Message);
            }
            finally
            {
                _stepTimer.StopTime();
            }

            if (success && ChildStep != null)
            {
                ChildStep.StartRun();
            }
        }
예제 #2
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();
            }
        }