Inheritance: UdpTrackerMessage
示例#1
0
        public void ConnectMessageTest()
        {
            var m = new ConnectMessage();
            var d = (ConnectMessage) UdpTrackerMessage.DecodeMessage(m.Encode(), 0, m.ByteLength, MessageType.Request);
            Check(m, MessageType.Request);

            Assert.AreEqual(0, m.Action, "#0");
            Assert.AreEqual(m.Action, d.Action, "#1");
            Assert.AreEqual(m.ConnectionId, d.ConnectionId, "#2");
            Assert.AreEqual(m.TransactionId, d.TransactionId, "#3");
            Assert.IsTrue(Toolbox.ByteMatch(m.Encode(), d.Encode()), "#4");
        }
示例#2
0
 protected override void ReceiveConnect(ConnectMessage connectMessage)
 {
     if (!IgnoreConnects)
         base.ReceiveConnect(connectMessage);
 }
示例#3
0
 protected virtual void ReceiveConnect(ConnectMessage connectMessage)
 {
     UdpTrackerMessage m = new ConnectResponseMessage(connectMessage.TransactionId, CreateConnectionID());
     byte[] data = m.Encode();
     listener.Send(data, data.Length, endpoint);
 }