Beispiel #1
0
        public override void HandleConnectionRequestFrame(AleTunnel theConnection, Frames.AleFrame theFrame)
        {
            var crData = theFrame.UserData as AleConnectionRequest;

            // 停止超时检测计时器。
            theConnection.StopHandshakeTimer();

            // 检查CR协议帧。
            this.CheckCrFrame(crData, theConnection);

            // 检查AU1的正确性。
            this.Context.AuMsgBuilder.CheckAu1Packet(crData.UserData);

            // 发送CC帧。
            this.SendConnectionConfirmFrame(theConnection);

            if (!this.Context.ContainsTunnel(theConnection))
            {
                // 事件通知:接收到一个新的TCP连接。
                var args = new TcpConnectedEventArgs(theConnection.ID,
                                                     this.Context.RsspEP.LocalID, theConnection.LocalEndPoint,
                                                     this.Context.RsspEP.RemoteID, theConnection.RemoteEndPoint);
                this.Context.TunnelEventNotifier.NotifyTcpConnected(args);

                // 增加有效的连接个数。
                theConnection.IsHandShaken = true;
                this.Context.IncreaseValidConnection();

                // 保存TCP连接
                this.Context.AddConnection(theConnection);
            }
        }
Beispiel #2
0
 private void OnTcpConnected(object sender, TcpConnectedEventArgs e)
 {
     try
     {
         _productCache.AddTail(e);
     }
     catch (System.Exception)
     {
     }
 }
Beispiel #3
0
        private void ShowTcpConnectedEvent(TcpConnectedEventArgs args)
        {
            try
            {
                this.Invoke(new Action(() =>
                {
                    var nodeKey  = args.ConnectionID;
                    var nodeText = String.Format("LEP_{0} + REP_{1}, Established at {2}.", args.LocalEndPoint, args.RemoteEndPoint, DateTime.Now.ToString());

                    // 添加RemoteNode
                    TreeNode theRemoteNode = null;
                    var theRemoteNodes     = treeViewNetwork.Nodes.Find(args.RemoteID.ToString(), false);

                    // 更新网络状态图
                    TreeNode theLinkNode = null;

                    if (theRemoteNodes.Length == 0)
                    {
                        if (args.RemoteID == this.SiblingID)
                        {
                            theRemoteNode = this.AddSibling(this.SiblingID);
                        }
                        else
                        {
                            theRemoteNode = this.AddClient(args.RemoteID);
                        }
                    }
                    else
                    {
                        theRemoteNode = theRemoteNodes[0];
                    }

                    // 查找TcpLink对应的节点。
                    var nodesTemp = theRemoteNode.Nodes.Find(nodeKey, false);
                    if (nodesTemp.Length > 0)
                    {
                        theLinkNode      = nodesTemp[0];
                        theLinkNode.Text = nodeText;
                    }
                    else
                    {
                        theLinkNode = theRemoteNode.Nodes.Add(nodeKey, nodeText);
                    }
                    theLinkNode.ForeColor        = Color.Black;
                    theLinkNode.ImageKey         = "success";
                    theLinkNode.SelectedImageKey = "success";
                }));
            }
            catch (System.Exception ex)
            {
                this.ShowLog(ex.Message);
            }
        }
Beispiel #4
0
 void IAleTunnelEventNotifier.NotifyTcpConnected(TcpConnectedEventArgs args)
 {
     try
     {
         if (this.TcpConnected != null)
         {
             this.TcpConnected(null, args);
         }
     }
     catch (System.Exception)
     {
     }
 }
Beispiel #5
0
        public void AddAleServerTunnel(AleServerTunnel tunnel)
        {
            tunnel.Observer = this;
            this.AddConnection(tunnel);

            //tunnel.IsHandShaken = true;
            //this.IncreaseValidConnection();

            // 事件通知:接收到一个新的TCP连接。
            var args = new TcpConnectedEventArgs(tunnel.ID,
                                                 this.RsspEP.LocalID, tunnel.LocalEndPoint,
                                                 this.RsspEP.RemoteID, tunnel.RemoteEndPoint);

            this.TunnelEventNotifier.NotifyTcpConnected(args);
        }
Beispiel #6
0
        public override void HandleTcpConnected(AleClientTunnel theConnection)
        {
            // TCP连接成功后发送CR。
            this.SendConnectionRequestFrame(theConnection);

            // 通知观察器TCP连接已建立。
            var args = new TcpConnectedEventArgs(theConnection.ID,
                                                 this.Context.RsspEP.LocalID, theConnection.LocalEndPoint,
                                                 this.Context.RsspEP.RemoteID, theConnection.RemoteEndPoint);

            this.Context.TunnelEventNotifier.NotifyTcpConnected(args);

            // 启动超时检测计时器。
            theConnection.StartHandshakeTimer();
        }
Beispiel #7
0
        public override void HandleConnectionRequestFrame(AleTunnel theConnection, AleFrame theFrame)
        {
            var crData = theFrame.UserData as AleConnectionRequest;

            // 停止握手计时器。
            theConnection.StopHandshakeTimer();

            // 复位序号。
            this.Context.SeqNoManager.Initlialize();

            // 检查CR协议帧。
            this.CheckCrFrame(crData, theConnection);

            // 更新服务类型。
            this.Context.RsspEP.ServiceType = crData.ServiceType;

            // 将CR帧中的AU1提交到MASL(主要更新RandomB)。
            this.Context.Observer.OnAleUserDataArrival(crData.UserData);

            // 发送CC帧。
            this.SendConnectionConfirmFrame(theConnection);

            // 更新序号管理器的发送序号与确认序号。
            this.Context.SeqNoManager.GetAndUpdateSendSeq();
            this.Context.SeqNoManager.UpdateAckSeq(theFrame.SequenceNo);

            if (!this.Context.ContainsTunnel(theConnection))
            {
                // 接收到一个新的TCP连接。
                var args = new TcpConnectedEventArgs(theConnection.ID,
                                                     this.Context.RsspEP.LocalID, theConnection.LocalEndPoint,
                                                     this.Context.RsspEP.RemoteID, theConnection.RemoteEndPoint);
                this.Context.TunnelEventNotifier.NotifyTcpConnected(args);

                // 增加有效的连接个数。
                theConnection.IsHandShaken = true;
                this.Context.IncreaseValidConnection();

                // 保存TCP连接
                this.Context.AddConnection(theConnection);
            }
        }
Beispiel #8
0
        public override void HandleTcpConnected(AleClientTunnel theConnection)
        {
            // 复位序号。
            this.Context.SeqNoManager.Initlialize();

            // TCP连接成功后发送ALE连接请求。
            this.SendConnectionRequestFrame(theConnection);

            // 通知观察器TCP连接已建立。
            var args = new TcpConnectedEventArgs(theConnection.ID,
                                                 this.Context.RsspEP.LocalID, theConnection.LocalEndPoint,
                                                 this.Context.RsspEP.RemoteID, theConnection.RemoteEndPoint);

            this.Context.TunnelEventNotifier.NotifyTcpConnected(args);

            // 设置下一个状态。
            this.Context.CurrentState = new AleWaitingForCcState(this.Context);

            // 启动握手超时计时器。
            theConnection.StartHandshakeTimer();
        }
Beispiel #9
0
 private void OnConnectedEventArgs(object sender, TcpConnectedEventArgs e)
 {
     throw new NotImplementedException();
 }