p2ps.imp.rendezvous
Class RendezvousConnection

java.lang.Object
  extended byp2ps.imp.rendezvous.RendezvousConnection
All Implemented Interfaces:
EndpointMessageListener

public class RendezvousConnection
extends java.lang.Object
implements EndpointMessageListener

A class that maintains a connection to a rendezvous peer. This connection can either be rendezvous-to-rendezvous or peer-to-rendezvous

Version:
$Revision: 295 $
Author:
Ian Wang

Field Summary
static int PEER_TO_RENDEZVOUS
           
static int RENDEZVOUS_TO_RENDEZVOUS
           
 
Constructor Summary
RendezvousConnection(int type, java.lang.String peerid, Endpoint endpoint, Peer peer)
           
 
Method Summary
 void acceptConnection()
          Initializes a connection to the rendezvous.
 void addConnectionListener(ConnectionListener listener)
          Add a connection listener
 void close()
          Closes the rendezvous connection
 void dataMessageReceived(DataMessageEvent event)
          Called when the endpoint receives a data message
 Endpoint getEndpoint()
           
 java.lang.String getPeerId()
           
 int getType()
           
 void initConnection()
          Initializes a connection to the rendezvous.
 boolean isConnectionAccepted()
           
 boolean isConnectionDeclined()
           
 void notifyConnectionAccepted()
           
 void notifyConnectionDeclined()
           
 void notifyConnectionFailed()
           
 void removeConnectionListener(ConnectionListener listener)
          Remove a connection listener
 void send(byte[] bytes)
          Sends the specified bytes to the connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PEER_TO_RENDEZVOUS

public static final int PEER_TO_RENDEZVOUS
See Also:
Constant Field Values

RENDEZVOUS_TO_RENDEZVOUS

public static final int RENDEZVOUS_TO_RENDEZVOUS
See Also:
Constant Field Values
Constructor Detail

RendezvousConnection

public RendezvousConnection(int type,
                            java.lang.String peerid,
                            Endpoint endpoint,
                            Peer peer)
Method Detail

initConnection

public void initConnection()
                    throws java.io.IOException
Initializes a connection to the rendezvous.

Throws:
java.io.IOException - if no connection could be established

acceptConnection

public void acceptConnection()
                      throws java.io.IOException
Initializes a connection to the rendezvous.

Throws:
java.io.IOException - if no connection could be established

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Add a connection listener


removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Remove a connection listener


getType

public int getType()
Returns:
the type of connection

getPeerId

public java.lang.String getPeerId()
Returns:
the peer id of the connected rendezvous

getEndpoint

public Endpoint getEndpoint()
Returns:
the endpoint for this connection

isConnectionAccepted

public boolean isConnectionAccepted()
Returns:
true if the connection has been accepted

isConnectionDeclined

public boolean isConnectionDeclined()
Returns:
true if the connection has been accepted

send

public void send(byte[] bytes)
          throws java.io.IOException
Sends the specified bytes to the connection. If no connection has been established then the bytes are not sent.

Throws:
java.io.IOException

close

public void close()
Closes the rendezvous connection


dataMessageReceived

public void dataMessageReceived(DataMessageEvent event)
Called when the endpoint receives a data message

Specified by:
dataMessageReceived in interface EndpointMessageListener

notifyConnectionAccepted

public void notifyConnectionAccepted()

notifyConnectionDeclined

public void notifyConnectionDeclined()

notifyConnectionFailed

public void notifyConnectionFailed()