/** * Send the request to connected hubs . * */ private void DispatchRequest(G2PacketQ2 pack) { int count = 0; NodePeer hub = null; while (count < Settings.PEER_DISPATCH_QUERY) { hub = G2Network.Instance.getQueryableHub(); hub.DontQueryBefore(Settings.SEARCH_TIME_OUT_MS); hub.SendPacket(pack); G2Log.Write("G2SearchManager : Sent Query " + getTermsByGUID(pack.guid) + " on " + hub.ToString()); count++; } }
/** * CHeck incoming message for this peer, and push a response if needed * */ private void OnNewMessage(NodePeer p) { G2Packet pack = null; G2Packet response = null; while ((pack = p.Buffer.PollPacketToReceive()) != null) { response = HandlePacket(p, pack); // network related packets (ping/pong/etc) if (response != null) { p.SendPacket(response); response = null; } if (pack.type == G2PacketType.QA || pack.type == G2PacketType.QH2) {// search related packets SearchManager.EnqueueResultPacket(p, pack); continue; } pack = null; } }
/** * CHeck incoming message for this peer, and push a response if needed * */ private void OnNewMessage(NodePeer p) { G2Packet pack = null; G2Packet response = null; while ((pack = p.Buffer.PollPacketToReceive ()) != null) { response = HandlePacket (p,pack); // network related packets (ping/pong/etc) if(response != null) { p.SendPacket (response); response = null; } if (pack.type == G2PacketType.QA || pack.type == G2PacketType.QH2) {// search related packets SearchManager.EnqueueResultPacket(p, pack); continue; } pack = null; } }