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

Quick Search    Search Deep

Freenet
Class Message  view Message download Message.java

java.lang.Object
  extended byFreenet.Message
Direct Known Subclasses:
Handshake

public abstract class Message
extends java.lang.Object

This is the abstract superclass of all messages


Field Summary
 long depth
          The number number of hops this message is from its originating node
 long hopsToLive
          The number of times this message should be forwarded before generating a TimedOutMessage
 long id
          A randomly generated unique ID used to identify related messages
 boolean keepAlive
          Whether the connection should be kept open after sending this
static java.lang.String messageName
           
private  java.util.Hashtable otherFields
          Any unknown / unused fields
 Address receivedAt
          Address of this node on the network that this message came from
 ConnectionHandler receivedWith
          ConnectionHandler that accepted that received message
 Address source
          The Address of the node where this message originated
 
Constructor Summary
Message(long idnum, long htl, long dpth)
           
Message(RawMessage raw)
           
 
Method Summary
private  long hextolong(java.lang.String hex)
           
 void initSources(Address me, Address peer, ConnectionHandler ch)
          Called by the connection handler after right constructing the message, while still in touch with the connection
protected  java.lang.String popField(java.lang.String s)
           
protected abstract  MessageMemory pReceived(Freenet.node.Node n, MessageMemory sb)
          An overridable version of the received message.
 MessageMemory received(Freenet.node.Node n, MessageMemory sb)
          Called by a node after this message is received.
 ConnectionHandler sendBack(Freenet.node.Node n, MessageMemory mm)
          Sends this message back to the node from which the chain was originally received.
 void sending(Core n, Address peer, Address myAddress)
          Called just before the message is sent, and makes any last minute changes.
 void sending(Core n, ConnectionHandler ch)
           
protected  ConnectionHandler sendReply(Freenet.node.Node n, Message m)
          Sends a message back to the node from which this message was received.
protected  MessageMemory timeOut(Freenet.node.Node n, MessageMemory sb)
           
 RawMessage toRawMessage()
           
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

messageName

public static final java.lang.String messageName
See Also:
Constant Field Values

source

public Address source
The Address of the node where this message originated


receivedAt

public Address receivedAt
Address of this node on the network that this message came from


receivedWith

public ConnectionHandler receivedWith
ConnectionHandler that accepted that received message


hopsToLive

public long hopsToLive
The number of times this message should be forwarded before generating a TimedOutMessage


depth

public long depth
The number number of hops this message is from its originating node


id

public long id
A randomly generated unique ID used to identify related messages


keepAlive

public boolean keepAlive
Whether the connection should be kept open after sending this


otherFields

private java.util.Hashtable otherFields
Any unknown / unused fields

Constructor Detail

Message

public Message(long idnum,
               long htl,
               long dpth)

Message

public Message(RawMessage raw)
        throws InvalidMessageException
Method Detail

popField

protected java.lang.String popField(java.lang.String s)

hextolong

private long hextolong(java.lang.String hex)
                throws java.lang.NumberFormatException

toRawMessage

public RawMessage toRawMessage()

initSources

public void initSources(Address me,
                        Address peer,
                        ConnectionHandler ch)
Called by the connection handler after right constructing the message, while still in touch with the connection


received

public final MessageMemory received(Freenet.node.Node n,
                                    MessageMemory sb)
Called by a node after this message is received. This allows message handling code to be packaged within the message class that is being handled.


sending

public void sending(Core n,
                    ConnectionHandler ch)
             throws SendFailedException

sending

public void sending(Core n,
                    Address peer,
                    Address myAddress)
             throws SendFailedException
Called just before the message is sent, and makes any last minute changes.


pReceived

protected abstract MessageMemory pReceived(Freenet.node.Node n,
                                           MessageMemory sb)
An overridable version of the received message.


timeOut

protected MessageMemory timeOut(Freenet.node.Node n,
                                MessageMemory sb)

sendReply

protected ConnectionHandler sendReply(Freenet.node.Node n,
                                      Message m)
                               throws SendFailedException
Sends a message back to the node from which this message was received. If a connection is open, that will be used, otherwise a new one opened


sendBack

public ConnectionHandler sendBack(Freenet.node.Node n,
                                  MessageMemory mm)
                           throws SendFailedException
Sends this message back to the node from which the chain was originally received.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).