public void Test_CreatePingResponse() { var tid = DHTTransactions.GetNextId(); var nodeId = DHTId.CreateRandom(); DHTMessage msg = DHTMessage.CreatePingResponse(tid, nodeId); Assert.IsNotNull(msg); Assert.AreEqual(MessageType.Response, msg.Type); // TODO: test contents }
private void OnRecvPingQuery(IPEndPoint ipinfo, BDictionary data) { var t = data.Get <BString>("t"); var args = data.Get <BDictionary>("a"); var id = args.Get <BString>("id"); fLogger.WriteDebug("Receive `ping` query from {0} [{1}]", ipinfo.ToString(), id.Value.ToHexString()); fRoutingTable.UpdateNode(new DHTNode(id.Value, ipinfo)); Send(ipinfo, DHTMessage.CreatePingResponse(t, fLocalID)); }
private void OnRecvPingQuery(IPEndPoint ipinfo, BDictionary data) { var t = data.Get <BString>("t"); var args = data.Get <BDictionary>("a"); var id = args.Get <BString>("id"); var remoteNode = new DHTNode(id.Value, ipinfo); UpdateRoutingTable(remoteNode); #if DEBUG_DHT_INTERNALS fLogger.WriteDebug("Receive `ping` query from {0}", remoteNode.ToString()); #endif Send(ipinfo, DHTMessage.CreatePingResponse(t, fLocalID)); }
private void OnRecvPingQuery(IPEndPoint ipinfo, BDictionary data, bool similar) { var t = data.Get <BString>("t"); var args = data.Get <BDictionary>("a"); var id = args.Get <BString>("id"); fLogger.WriteDebug("Receive `ping` query from {0} [{1}]", ipinfo.ToString(), id.Value.ToHexString()); fRoutingTable.UpdateNode(new DHTNode(id.Value, ipinfo)); // FIXME: temp debug code if (similar) { fLogger.WriteDebug(">>>>>>>>>>>> Found a similar peer! " + ipinfo.ToString()); } Send(ipinfo, DHTMessage.CreatePingResponse(t, fLocalID)); }