Esempio n. 1
0
 public Message CreateSearchRequestMessage(int searchRequestId, string searchString, int page)
 {
     Message p = new Message(network, MessageType.SearchRequest);
     SearchRequestInfo c = new SearchRequestInfo(searchRequestId, searchString, page);
     p.Content = c;
     return p;
 }
Esempio n. 2
0
        internal void ProcessSearchRequestMessage(Node messageFrom, SearchRequestInfo searchRequest)
        {
            lock (SeenSearchRequests) {
                if (SeenSearchRequests.ContainsKey(searchRequest.Id)) {
                    return; // Ignore. We probably saw this same request from the same person
                            // on multiple networks.
                } else {
                    // Store timestamp so we can cleanup the list later.
                    // XXX: Cleanup not implemented yet
                    SeenSearchRequests[searchRequest.Id] = DateTime.Now;
                }
            }

            SearchResultInfo reply = Core.FileSystem.SearchFiles(searchRequest.Query);
            reply.SearchId = searchRequest.Id;

            if (reply.Files.Length > 0 || reply.Directories.Length > 0) {
                network.SendSearchReply(messageFrom, reply);
            }
        }