Inheritance: UdpTrackerMessage
Esempio n. 1
0
        public void ConnectResponseTest()
        {
            var expectedMessage = new ConnectResponseMessage(5371, 12345);
            var actualMessage =
                (ConnectResponseMessage)
                UdpTrackerMessage.DecodeMessage(expectedMessage.Encode(), 0, expectedMessage.ByteLength, MessageType.Response);
            Check(expectedMessage, MessageType.Response);

            Assert.AreEqual(0, expectedMessage.Action, "#0");
            Assert.AreEqual(expectedMessage.Action, actualMessage.Action, "#1");
            Assert.AreEqual(expectedMessage.ConnectionId, actualMessage.ConnectionId, "#2");
            Assert.AreEqual(expectedMessage.TransactionId, actualMessage.TransactionId, "#3");
            Assert.IsTrue(Toolbox.ByteMatch(expectedMessage.Encode(), actualMessage.Encode()), "#4");
            Assert.AreEqual(12345, actualMessage.ConnectionId);
            Assert.AreEqual(5371, actualMessage.TransactionId);
        }
Esempio n. 2
0
 protected virtual void ReceiveConnect(ConnectMessage connectMessage)
 {
     UdpTrackerMessage m = new ConnectResponseMessage(connectMessage.TransactionId, CreateConnectionID());
     byte[] data = m.Encode();
     listener.Send(data, data.Length, endpoint);
 }