/// <summary> /// 构造函数 /// </summary> public BitFieldMessage(EncryptedConnection encryptedConnection, Connection connection, Connecter connecter) : base(encryptedConnection) { this.connection = connection; this.connecter = connecter; this.InitialBytesLength(connecter.PiecesNumber); }
public void Test3() { DummyConnecter c = new DummyConnecter(); DummyRawServer rs = new DummyRawServer(); Encrypter 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); e.FlushConnection(c1); c1.Pop(); byte[] bytes = new byte[48]; 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; } e.DataCameIn(c1, bytes); c1.Pop(); bytes = new byte[20]; for (i = 0; i < 20; i++) { bytes[i] = (byte)'b'; } e.DataCameIn(c1, bytes); c1.Pop(); EncryptedConnection ch = (EncryptedConnection)((object[])c.log[0])[1]; c.log.Clear(); Assert.AreEqual(0, rs.connects.Count); Assert.AreEqual(false, c1.Closed); Assert.AreEqual(true, ch.IsFlushed); e.FlushConnection(c1); c1.Pop(); c1.SetFlushed(false); Assert.AreEqual(false, ch.IsFlushed); }