Esempio n. 1
0
        public override void SendUserData(byte[] maslPacket)
        {
            var aleData   = new AleDataTransmission(maslPacket);
            var seqNo     = (ushort)this.Context.SeqNoManager.GetAndUpdateSendSeq();
            var appType   = this.Context.RsspEP.ApplicatinType;
            var dataFrame = new AleFrame(appType, seqNo, false, aleData);

            // send
            if (this.Context.RsspEP.ServiceType == ServiceType.A)
            {
                this.Context.Tunnels.ToList().ForEach(connection =>
                {
                    if (connection.IsActive)
                    {
                        dataFrame.IsNormal = connection.IsNormal;
                        var bytes          = dataFrame.GetBytes();
                        connection.Send(bytes);
                    }
                });
            }
            else
            {
                dataFrame.IsNormal = false;
                var bytes = dataFrame.GetBytes();
                this.Context.Tunnels.ToList().ForEach(connection =>
                {
                    connection.Send(bytes);
                });
            }
        }
Esempio n. 2
0
        public void Test3()
        {
            var aleData1 = new AleDataTransmission()
            {
                UserData = new byte[] { 100, 200 }
            };

            var aleFrame1 = new AleFrame(1, 111, false, aleData1);

            aleFrame1.Version         = 1;
            aleFrame1.ApplicationType = 22;
            aleFrame1.SequenceNo      = 300;

            Assert.AreEqual(AleFrameType.DataTransmission, aleFrame1.FrameType);

            var bytes = aleFrame1.GetBytes();

            var aleFrame2 = new AleFrame();

            aleFrame2.ParseBytes(bytes);

            Assert.AreEqual(aleFrame2.Version, aleFrame1.Version);
            Assert.AreEqual(aleFrame2.ApplicationType, aleFrame1.ApplicationType);
            Assert.AreEqual(aleFrame2.SequenceNo, aleFrame1.SequenceNo);
            Assert.AreEqual(aleFrame2.IsNormal, aleFrame1.IsNormal);

            var aleData2 = aleFrame2.UserData as AleDataTransmission;

            Assert.NotNull(aleData2);
            Assert.AreEqual(aleData1.UserData[0], aleData2.UserData[0]);
            Assert.AreEqual(aleData1.UserData[1], aleData2.UserData[1]);
        }
Esempio n. 3
0
        public void Test2()
        {
            var aleData1 = new AleConnectionConfirm()
            {
                ServerID = 10,
            };

            var aleFrame1 = new AleFrame(1, 111, false, aleData1);

            aleFrame1.Version         = 1;
            aleFrame1.ApplicationType = 22;
            aleFrame1.SequenceNo      = 300;

            Assert.AreEqual(AleFrameType.ConnectionConfirm, aleFrame1.FrameType);

            var bytes = aleFrame1.GetBytes();

            var aleFrame2 = new AleFrame();

            aleFrame2.ParseBytes(bytes);

            Assert.AreEqual(aleFrame2.Version, aleFrame1.Version);
            Assert.AreEqual(aleFrame2.ApplicationType, aleFrame1.ApplicationType);
            Assert.AreEqual(aleFrame2.SequenceNo, aleFrame1.SequenceNo);
            Assert.AreEqual(aleFrame2.IsNormal, aleFrame1.IsNormal);

            var aleData2 = aleFrame2.UserData as AleConnectionConfirm;

            Assert.NotNull(aleData2);
            Assert.AreEqual(aleData1.ServerID, aleData2.ServerID);
        }
Esempio n. 4
0
        public void Test1()
        {
            var aleData1 = new AleConnectionRequest()
            {
                InitiatorID = 10, ResponderID = 20, @ServiceType = ServiceType.D
            };

            var aleFrame1 = new AleFrame(1, 111, false, aleData1);

            aleFrame1.Version         = 1;
            aleFrame1.ApplicationType = 22;
            aleFrame1.SequenceNo      = 300;

            Assert.AreEqual(AleFrameType.ConnectionRequest, aleFrame1.FrameType);

            var bytes = aleFrame1.GetBytes();

            var aleFrame2 = new AleFrame();

            aleFrame2.ParseBytes(bytes);

            Assert.AreEqual(aleFrame2.Version, aleFrame1.Version);
            Assert.AreEqual(aleFrame2.ApplicationType, aleFrame1.ApplicationType);
            Assert.AreEqual(aleFrame2.SequenceNo, aleFrame1.SequenceNo);
            Assert.AreEqual(aleFrame2.IsNormal, aleFrame1.IsNormal);

            var aleData2 = aleFrame2.UserData as AleConnectionRequest;

            Assert.NotNull(aleData2);
            Assert.AreEqual(aleData1.InitiatorID, aleData2.InitiatorID);
            Assert.AreEqual(aleData1.ResponderID, aleData2.ResponderID);
            Assert.AreEqual(aleData1.ServiceType, aleData2.ServiceType);
        }
Esempio n. 5
0
        public virtual void Disconnect(byte[] diSaPDU)
        {
            var seqNo   = (ushort)this.Context.SeqNoManager.GetAndUpdateSendSeq();
            var appType = this.Context.RsspEP.ApplicatinType;
            var aleData = new AleDisconnect(diSaPDU);

            var dataFrame = new AleFrame(appType, seqNo, false, aleData);
            var bytes     = dataFrame.GetBytes();

            var tcpLinks = this.Context.Tunnels.ToList();

            tcpLinks.ForEach(connection =>
            {
                connection.Send(bytes);
                connection.Disconnect();
            });
        }
Esempio n. 6
0
        protected void SendConnectionConfirmFrame(AleTunnel theConnection)
        {
            var au2Packet = this.Context.AuMsgBuilder.BuildAu2Packet();

            var ccData = new AleConnectionConfirm(this.Context.RsspEP.LocalID, au2Packet);

            // 构建AleFrame。
            ushort seqNo   = 0;
            var    appType = this.Context.RsspEP.ApplicatinType;
            var    ccFrame = new AleFrame(appType, seqNo, theConnection.IsNormal, ccData);

            // 发送。
            var bytes = ccFrame.GetBytes();

            theConnection.Send(bytes);

            LogUtility.Info(string.Format("{0}: Send CC frame via tcp connection(LEP = {1}, REP={2}).",
                                          this.Context.RsspEP.ID, theConnection.LocalEndPoint, theConnection.RemoteEndPoint));
        }