예제 #1
0
 public void GetMessage(IEncryptedConnection encryptedConnection, byte[] message)
 {
     log.Add(new object[] { "get ", encryptedConnection, message });
     Console.WriteLine("Connecter Get Message:{0}", this.closeNext);
     if (this.closeNext)
     {
         Console.WriteLine("Connecter close Encrypted Connection");
         encryptedConnection.Close();
     }
 }
예제 #2
0
        public void Test11()
        {
            DummyConnecter    c  = new DummyConnecter();
            DummyRawServer    rs = new DummyRawServer();
            IEncrypter        e  = new Encrypter(c, rs, new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 500, DummySchedule, 30, new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, 40);
            DummySingleSocket c1 = new DummySingleSocket();

            e.MakeExternalConnection(c1);
            Assert.AreEqual(0, c.log.Count);
            Assert.AreEqual(0, rs.connects.Count);
            Assert.AreEqual(false, c1.Closed);

            byte[] bytes = new byte[68];
            bytes[0] = 19;
            Buffer.BlockCopy(Encoding.Default.GetBytes(protocolName), 0, bytes, 1, 19);

            int i;

            for (i = 0; i < 8; i++)
            {
                bytes[20 + i] = 0;
            }
            for (i = 0; i < 20; i++)
            {
                bytes[28 + i] = 1;
                bytes[48 + i] = 2;
            }
            e.DataCameIn(c1, bytes);
            Assert.AreEqual(1, c.log.Count);
            IEncryptedConnection ch = (EncryptedConnection)((object[])c.log[0])[1];

            c.log.Clear();
            Assert.AreEqual(false, c1.Closed);

            ch.Close();
            Assert.AreEqual(true, c1.Closed);
        }
예제 #3
0
 /// <summary>
 /// 关闭连接
 /// </summary>
 public void Close()
 {
     encryptedConnection.Close();
 }