p2ps.imp.pipe
Class PipeConnectHandler

java.lang.Object
  extended byp2ps.imp.pipe.PipeConnectHandler
All Implemented Interfaces:
DiscoveryListener, MessageListener

public class PipeConnectHandler
extends java.lang.Object
implements DiscoveryListener, MessageListener

A class that handles the resolving and connecting of output pipes, including the searching for appropriate resolvers.

TODO: time out connect events TODO: publish resolver query if existing resolvers fail

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
PipeConnectHandler(Peer peer)
          Connects an output pipe to the specified pipe
 
Method Summary
 void addPipeConnectionListener(PipeConnectionListener listener)
          Adds a pipe connection listener to the pipe service
 void advertDiscovered(DiscoveryEvent event)
           
 void connectOutputPipe(PipeAdvertisement pipead)
          Tries to create a new output pipe, notifies registered PipeConnectionListeners.
 void connectOutputPipe(PipeAdvertisement pipead, java.net.URI endpointuri)
          Creates an output pipe from a resolved endpoint
 void handleEndpointAdvertisement(EndpointAdvertisement advert)
          Called when a pipe is resolved
 void init()
           
 void messageReceived(MessageReceivedEvent event)
          Called when a message is received by the pipe
 void removePipeConnectionListener(PipeConnectionListener listener)
          Removes a pipe connection listener from the pipe service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PipeConnectHandler

public PipeConnectHandler(Peer peer)
Connects an output pipe to the specified pipe

Method Detail

init

public void init()
          throws java.io.IOException
Throws:
java.io.IOException

addPipeConnectionListener

public void addPipeConnectionListener(PipeConnectionListener listener)
Adds a pipe connection listener to the pipe service


removePipeConnectionListener

public void removePipeConnectionListener(PipeConnectionListener listener)
Removes a pipe connection listener from the pipe service


connectOutputPipe

public void connectOutputPipe(PipeAdvertisement pipead)
                       throws java.io.IOException
Tries to create a new output pipe, notifies registered PipeConnectionListeners.

Throws:
java.io.IOException

connectOutputPipe

public void connectOutputPipe(PipeAdvertisement pipead,
                              java.net.URI endpointuri)
                       throws UnknownSchemeException,
                              java.io.IOException
Creates an output pipe from a resolved endpoint

Throws:
UnknownSchemeException
java.io.IOException

messageReceived

public void messageReceived(MessageReceivedEvent event)
Called when a message is received by the pipe

Specified by:
messageReceived in interface MessageListener

advertDiscovered

public void advertDiscovered(DiscoveryEvent event)
Specified by:
advertDiscovered in interface DiscoveryListener

handleEndpointAdvertisement

public void handleEndpointAdvertisement(EndpointAdvertisement advert)
Called when a pipe is resolved