/** * Remove the search from the entries and * and delete objects * */ public void FinishSearch(G2SearchResults results) { G2SearchResults r; SearchTransaction t; bool generalSuccess = false; generalSuccess |= SearchResults.TryRemove(results.SearchGUID, out r); generalSuccess &= SearchDB.TryRemove(results.SearchGUID, out t); results.Clean(); }
/** * 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 }
/** * Take a search related packets i.e. QA (ack) or QH2 (hit) * and stores it into SearchResults class * */ public void EnqueueResultPacket(NodePeer p, G2Packet pack) { // a hub packet ACK a query if (pack.type == G2PacketType.QA) { G2PacketQA qa = pack as G2PacketQA; G2SearchResults res = null; bool exists = SearchResults.TryGetValue(qa.guid, out res); if (!exists) // no entry => not a search we initiated { G2Log.Write("G2SearchManager : Received ACK of non asked Query"); } else { res.SetAcknowledgement(qa); G2Log.Write("G2SearchManager Received ACK of search " + SearchDB[qa.guid].Keywords[0]); } } // Hit packet ! else if (pack.type == G2PacketType.QH2) { G2PacketQH2 qh2 = pack as G2PacketQH2; G2SearchResults res = null; bool exists = SearchResults.TryGetValue(qh2.searchGuid, out res); if (exists) { // a new result packet coming for a requested query res.PushResultPacket(qh2); //if (res.TotalFiles > MAX_RESULTS) // G2Network.Instance.StopNetwork(); } else // got a response for a query we did not ask ? { G2Log.Write("G2SearchManager : Received a Hit on a NON ASKED Query"); } } }
/** * 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 }
/** * Remove the search from the entries and * and delete objects * */ public void FinishSearch(G2SearchResults results) { G2SearchResults r ; SearchTransaction t; bool generalSuccess = false; generalSuccess |= SearchResults.TryRemove(results.SearchGUID,out r); generalSuccess &= SearchDB.TryRemove(results.SearchGUID, out t); results.Clean(); }