JXTA

net.jxta.impl.endpoint.msgframing
Class WelcomeMessage

java.lang.Object
  extended by net.jxta.impl.endpoint.msgframing.WelcomeMessage

public class WelcomeMessage
extends Object

Contains a JXTA connection Welcome Message. The Welcome Message is sent by both participant peers as the first interchange on newly opened connections.

The Welcome Message contains the following information:

See Also:
JXTA Protocols Specification : TCP/IP Message Transport

Constructor Summary
WelcomeMessage()
          Default constructor
WelcomeMessage(EndpointAddress destAddr, EndpointAddress publicaddress, ID peerid, boolean dontPropagate)
          Creates a new instance of WelcomeMessage for our Welcome Message.
WelcomeMessage(EndpointAddress destAddr, EndpointAddress publicaddress, ID peerid, boolean dontPropagate, int preferredMsgVersion)
          Creates a new instance of WelcomeMessage for our Welcome Message.
WelcomeMessage(InputStream in)
          Creates a new instance of WelcomeMessage for another peer's Welcome Message
 
Method Summary
 boolean dontPropagate()
          Return the propagation preference from the Welcome Message.
 ByteBuffer getByteBuffer()
          Write the welcome to a socket channel
 EndpointAddress getDestinationAddress()
          Return the destination address associated with the Welcome Message.
 ID getPeerID()
          Return the peerid associated with the Welcome Message.
 int getPreferredMessageVersion()
          Return the preferred message version from the Welcome Message.
 EndpointAddress getPublicAddress()
          Return the source address associated with the Welcome Message.
 String getWelcomeString()
          Return a String containing the Welcome Message.
 String getWelcomeVersion()
          Return the version associated with the Welcome Message.
 boolean read(ByteBuffer buffer)
          Attempts to init a welcome object from a socketChannel
 void sendToStream(OutputStream theStream)
          Write the welcome message to the provided stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WelcomeMessage

public WelcomeMessage()
Default constructor


WelcomeMessage

public WelcomeMessage(EndpointAddress destAddr,
                      EndpointAddress publicaddress,
                      ID peerid,
                      boolean dontPropagate)
Creates a new instance of WelcomeMessage for our Welcome Message.

Parameters:
destAddr - The destination address that we believe we are connecting to.
publicaddress - Our return address, the purported source address of this connection.
peerid - Our peerid, the logical return address.
dontPropagate - If true this connection does not wish to receive any propagation/broadcast/notifications.

WelcomeMessage

public WelcomeMessage(EndpointAddress destAddr,
                      EndpointAddress publicaddress,
                      ID peerid,
                      boolean dontPropagate,
                      int preferredMsgVersion)
Creates a new instance of WelcomeMessage for our Welcome Message.

Parameters:
destAddr - The destination address that we believe we are connecting to.
publicaddress - Our return address, the purported source address of this connection.
peerid - Our peerid, the logical return address.
dontPropagate - If true this connection does not wish to receive any propagation/broadcast/notifications.
preferredMsgVersion - Binary Wire Messsage format we prefer.

WelcomeMessage

public WelcomeMessage(InputStream in)
               throws IOException
Creates a new instance of WelcomeMessage for another peer's Welcome Message

Parameters:
in - The InputStream to read the welcome message from.
Throws:
IOException - If there is a problem reading the welcome header.
Method Detail

read

public boolean read(ByteBuffer buffer)
             throws IOException
Attempts to init a welcome object from a socketChannel

Parameters:
buffer - the data buffer
Returns:
null if incomplete welcome was received
Throws:
IOException - if an io error occurs

sendToStream

public void sendToStream(OutputStream theStream)
                  throws IOException
Write the welcome message to the provided stream.

Parameters:
theStream - The OutputStream to which to write the welcome message.
Throws:
IOException - If there is a problem writing the welcome message.

getByteBuffer

public ByteBuffer getByteBuffer()
                         throws IOException
Write the welcome to a socket channel

Returns:
A ByteBuffer of the welcome message
Throws:
IOException - if an io error occurs

getPeerID

public ID getPeerID()
Return the peerid associated with the Welcome Message.

Returns:
The peer ID from the Welcome Message.

getPublicAddress

public EndpointAddress getPublicAddress()
Return the source address associated with the Welcome Message.

Returns:
The source address from the Welcome Message.

getDestinationAddress

public EndpointAddress getDestinationAddress()
Return the destination address associated with the Welcome Message.

Returns:
The destination address from the Welcome Message.

dontPropagate

public boolean dontPropagate()
Return the propagation preference from the Welcome Message.

Returns:
true if no propagation is desired otherwise false

getPreferredMessageVersion

public int getPreferredMessageVersion()
Return the preferred message version from the Welcome Message.

Returns:
The preferred Message Version.

getWelcomeVersion

public String getWelcomeVersion()
Return the version associated with the Welcome Message.

Returns:
The version from the Welcome Message.

getWelcomeString

public String getWelcomeString()
Return a String containing the Welcome Message.

Returns:
a String containing the Welcome Message.

JXSE