Source code: Freenet/message/TimedOut.java
1 package Freenet.message;
2 import Freenet.*;
3 import Freenet.node.*;
4 import Freenet.support.Logger;
5 import java.io.*;
6
7 /*
8 This code is part of the Java Adaptive Network Client by Ian Clarke.
9 It is distributed under the GNU Public Licence (GPL) version 2. See
10 http://www.gnu.org/ for further details of the GPL.
11
12 Explanation of Code Versions:
13 0.0.0 = Initial Description
14 0.0.1 = API Specified
15 0.x (x>0) = Partial Implementation
16 x.0 (x>0) = Operational
17
18 Requires Classes: Node (1.0)
19 Address (1.0)
20 Message (1.0)
21 */
22
23 /**
24 * This is the TimedOut message
25 *
26 * @see Node
27 * @see Address
28 * @author Brandon Wiley (blanu@uts.cc.utexas.edu)
29 * @author Ian Clarke (I.Clarke@strs.co.uk)
30 **/
31
32 public class TimedOut extends Message
33 {
34
35 public static final String messageName = "TimedOut";
36
37 public TimedOut(long idnum, long htl)
38 {
39 super(idnum, htl, (long)0);
40 this.keepAlive = false;
41 }
42
43 public TimedOut(RawMessage raw) throws InvalidMessageException
44 {
45 super(raw);
46 this.keepAlive = false;
47 }
48
49 public RawMessage toRawMessage()
50 {
51 RawMessage raw=super.toRawMessage();
52 raw.messageType="TimedOut";
53 return raw;
54 }
55
56 /**
57 * Called by a node after it receives this message
58 * @param n The node that called this message. This should be used
59 * to make any nescessary modifications to the DataStore etc.
60 * @param sb Null unless this node has been seen before. If non-null it
61 * is the Object returned by the received method of the
62 * last message seen with this ID.
63 * @return The object to be passed to any messages received in the near
64 * future with the same ID as this one. Null if no object should
65 * be passed.
66 **/
67 public MessageMemory pReceived(Node n, MessageMemory sb)
68 {
69 if(sb==null) // No one requested this, or I forgot about it
70 return null;
71 else // Forward it to whoever requested it.
72 {
73 Node.timer.cancel(id);
74 try {
75 sendBack(n, sb);
76 } catch (SendFailedException sfe) {
77 Logger.log("message/TimedOut.java","Send failed on return to " + sfe.peer,Logger.NORMAL);
78 }
79 return null;
80 }
81 }
82
83 protected MessageMemory timeOut(Node n, MessageMemory sb)
84 {
85 Logger.log("message/TimedOut.java","Errant TimedOut message died",Logger.NORMAL);
86 return null;
87 }
88 }
89
90