Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: Freenet/message/NameListRequest.java


1   package Freenet.message;
2   import Freenet.*;
3   import Freenet.support.*;
4   import java.util.*;
5   import java.io.*;
6   
7   public class NameListRequest extends Message {
8   
9     public NameListRequest(long idnum, long htl, long depth)
10    {
11      super(idnum, htl, depth);
12    }
13  
14    public NameListRequest(RawMessage raw) throws InvalidMessageException
15    {
16      super(raw);
17    }
18  
19    public RawMessage toRawMessage()
20    {
21      RawMessage raw=super.toRawMessage();
22      raw.messageType="NameListRequest";
23      return raw;
24    }
25  
26    /**
27     * Called by a node after it receives this message
28     * @param n The node that called this message.  This should be used
29     *          to make any nescessary modifications to the DataStore etc.
30     * @param sb Null unless this node has been seen before.  If non-null it
31     *           is the Object returned by the received method of the
32     *           last message seen with this ID.
33     * @return The object to be passed to any messages received in the near
34     *         future with the same ID as this one.  Null if no object should
35     *         be passed.
36     **/
37    public MessageMemory pReceived(Node n, MessageMemory sb)
38    {
39      try
40      {
41      FileOutputStream po=new FileOutputStream(".freenet/NL"+new Long(id).toString());
42      PrintWriter pr=new PrintWriter(po);
43      Enumeration iterator=n.ds.keys();
44      while(iterator.hasMoreElements())
45      {
46        StringKey s = (StringKey)iterator.nextElement();
47        System.out.println(s);
48        pr.println(s);
49  //      pr.println(iterator.nextElement());
50      }
51      pr.flush();
52      pr.close();
53      po.flush();
54      po.close();
55      Data data=new Data(new FileInputStream(".freenet/NL"+new Long(id).toString()));
56      DataReply drm=new DataReply(id, depth, (long)(Math.abs(new Random().nextInt() % 200)), null, data);
57      n.sendMessage(drm, source);
58      } 
59      catch(Exception e) {e.printStackTrace();}
60  
61      return sb;
62    }
63  }
64