public void Test2() { 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); 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); bytes = new byte[20]; for (i = 0; i < 20; i++) { bytes[i] = (byte)'b'; } e.DataCameIn(c1, bytes); c1.Pop(); IEncryptedConnection ch = (EncryptedConnection)((object[])c.log[0])[1]; c.log.Clear(); Encoding.Default.GetBytes(ch.IP); ch.SendMessage(new byte[] { (byte)'a', (byte)'b', (byte)'c' }); c1.Pop(); bytes = new byte[] { 0, 0, 0, 3, (byte)'d', (byte)'e', (byte)'f' }; e.DataCameIn(c1, bytes); c1.Pop(); }
/// <summary> /// 发送choke信息 /// choke: <len=0001><id=0> /// </summary> public void SendChoke() { //发送choke信息 message = MessageFactory.GetChokeMessage(); encryptedConnection.SendMessage(message.GetByteArray()); }