Esempio n. 1
0
        /**
         * Create a single request packet for the specified term
         * this request has id searchGUID
         * */
        private G2PacketQ2 CreateRequestPacket(GUID searchGUID, string singleTerm)
        {
            G2PacketQ2 q2 = new G2PacketQ2(searchGUID);              // id of the query
            G2PacketDN dn = new G2PacketDN(singleTerm);              // terms of the query

            q2.AddChild(dn);
            q2.FinalizePacket();
            return(q2);
        }
Esempio n. 2
0
        /**
         * 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++;
            }
        }
Esempio n. 3
0
        /**
         * Launch a new search on multiple hubs (starting)
         * SearchTransaction contains only one keyword
         * */
        public void NewSearch(SearchTransaction transaction)
        {
            // register query
            GUID searchGUID = GUID.generateGuid();

            SearchDB [searchGUID] = transaction;
            // creating a new search results object for this transaction, register the event that tell it has fins events and stores it
            G2SearchResults results = new G2SearchResults(transaction, searchGUID);

            SearchResults[searchGUID] = results;

            G2PacketQ2 q2 = CreateRequestPacket(searchGUID, transaction.Keywords[0].KeywordName);

            DispatchRequest(q2);
            results.StartSearchResult(); // start the threads only after all queries have been sent
            // because find new hub can take some time and the search may not last long after
        }