/// <summary>
        /// 处理端口缓冲区收到的端口数据。
        /// </summary>
        protected virtual void ProcessReceivedData(NetworkData networkData)
        {
            IConnection connection = this.connectionDocker.GetCase(networkData.RemoteHost.TaskTag);

            if (connection != null && connection is RefactorRequestChannel)
            {
                connection.Receiving = false;
                RefactorRequestChannel requestChannel = (RefactorRequestChannel)connection;
                if (requestChannel.Sender.TotalSendTimes != NetworkConstants.WAIT_FOR_COMPLETE)
                {
                    requestChannel.Sender.EndSend();
                }
            }
        }
        /// <summary>
        /// 处理端口缓冲区收到的端口数据。
        /// </summary>
        protected virtual void ProcessReceivedData(NetworkData networkData)
        {
            IConnection connection = this.connectionDocker.GetCase(networkData.RemoteHost.TaskTag);

            if (connection != null && connection is RefactorRequestChannel)
            {
                string content = connection.Encoder.ByteEncode(networkData.Buffer);
                string log     = String.Format("{0}:协议层消息处理【{1}】:{2}",
                                               DateTime.Now.ToString("hh:mm:ss"), networkData.RemoteHost.ToString(), content);
                Console.WriteLine(log);
                RefactorRequestChannel requestChannel = (RefactorRequestChannel)connection;
                requestChannel.StopReceive();
            }
        }
Exemple #3
0
 /// <summary>
 /// 检查协议关联的任务超时
 /// </summary>
 /// <param name="connection"></param>
 public void SetTaskTimeout(IConnection connection)
 {
     if (connection == null || TaskList.Count == 0)
     {
         return;
     }
     foreach (var task in TaskList.Where(o => o.GetRelatedProtocol() != null && o.GetRelatedProtocol().ControlCode == connection.ControlCode))
     {
         if (connection is RefactorRequestChannel)
         {
             RefactorRequestChannel requestChannel = (RefactorRequestChannel)connection;
             if (DateTime.Now.Subtract(task.ProcessingTime).TotalMilliseconds > requestChannel.Sender.TimeoutMS && requestChannel.Sender.TimeoutMS > 0)
             {
                 task.SetAsOvertime();
             }
         }
     }
 }
 protected RefactorResponseChannel(ReactorBase reactor, RefactorRequestChannel request, INode node)
 {
     _reactor       = reactor;
     requestChannel = request;
     Decoder        = _reactor.Decoder.Clone();
     Encoder        = _reactor.Encoder.Clone();
     Allocator      = _reactor.Allocator;
     Local          = reactor.LocalEndpoint;
     if (node != null)
     {
         RemoteHost = node;
     }
     else
     {
         RemoteHost = reactor.LocalEndpoint.Clone() as INode;
     }
     Timeout      = NetworkConstants.BackoffIntervals[6];
     this.Created = DateTime.Now;
     Dead         = false;
 }
        /// <summary>
        /// 处理端口缓冲区收到的端口数据。
        /// </summary>
        protected virtual void ProcessReceivedData(NetworkData networkData)
        {
            FrameBase frameBase = this.ParsingReceivedData(networkData.Buffer);

            if (frameBase.Equals(FrameBase.ResultOfParsingFrame.ReceivingCompleted))
            {
                IConnection connection = this.GetConnection(frameBase);
                if (connection != null && connection is RefactorRequestChannel)
                {
                    connection.Receiving = false;
                    RefactorRequestChannel requestChannel = (RefactorRequestChannel)connection;
                    if (requestChannel.Sender.TotalSendTimes != NetworkConstants.WAIT_FOR_COMPLETE)
                    {
                        requestChannel.Sender.EndSend();
                    }
                }
            }
            else
            {
                LogAgent.Info("丢弃非法数据-->>" + this.Encoder.ByteEncode(networkData.Buffer));
            }
        }
        //protected ICircularBuffer<NetworkData> UnreadMessages = new ConcurrentCircularBuffer<NetworkData>(1000);

        protected RefactorResponseChannel(ReactorBase reactor, RefactorRequestChannel request)
            : this(reactor, request, request.RemoteHost)
        {
        }
 public RefactorProxyResponseChannel(ReactorBase reactor, RefactorRequestChannel request, INode endPoint)
     : base(reactor, request, endPoint)
 {
 }
 public RefactorProxyResponseChannel(ReactorBase reactor, RefactorRequestChannel request)
     : this(reactor, request, reactor.LocalEndpoint)
 {
 }
 public DefaultResponse(ReactorBase reactor, RefactorRequestChannel request)
     : base(reactor, request)
 {
 }