p2ps.imp.pipe
Class BidirectionalPipeImp

java.lang.Object
  extended byp2ps.imp.pipe.BidirectionalPipeImp
All Implemented Interfaces:
BidirectionalPipe, EndpointMessageListener, InputPipe, OutputPipe

public class BidirectionalPipeImp
extends java.lang.Object
implements BidirectionalPipe, EndpointMessageListener

A bidirectional pipe based on an underlying input pipe and output pipe

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
BidirectionalPipeImp(PipeAdvertisement pipead, Endpoint[] endpoints)
           
 
Method Summary
 void addMessageListener(MessageListener listener)
          Adds a listener to be notified when messages are received
 void close()
          Closes the pipe
 void dataMessageReceived(DataMessageEvent event)
          Called when the endpoint receives a data message
 Endpoint[] getEndpoints()
           
 java.lang.String getPipeID()
           
 java.lang.String getPipeName()
           
 java.net.URI getPipeURI()
           
 java.net.URI getSendURI()
           
 boolean isClosed()
           
 void removeMessageListener(MessageListener listener)
          Removes a listener from being notified when messages are received
 java.lang.String send(byte[] message)
          Sends a message from the pipe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BidirectionalPipeImp

public BidirectionalPipeImp(PipeAdvertisement pipead,
                            Endpoint[] endpoints)
Method Detail

addMessageListener

public void addMessageListener(MessageListener listener)
Adds a listener to be notified when messages are received

Specified by:
addMessageListener in interface InputPipe

removeMessageListener

public void removeMessageListener(MessageListener listener)
Removes a listener from being notified when messages are received

Specified by:
removeMessageListener in interface InputPipe

getPipeURI

public java.net.URI getPipeURI()
Specified by:
getPipeURI in interface InputPipe
Returns:
the uri of the pipe

getSendURI

public java.net.URI getSendURI()
Specified by:
getSendURI in interface OutputPipe
Returns:
the uri sent to by this pipe (null if unknown)

getPipeID

public java.lang.String getPipeID()
Specified by:
getPipeID in interface InputPipe
Returns:
the id of the pipe

getPipeName

public java.lang.String getPipeName()
Specified by:
getPipeName in interface InputPipe
Returns:
the name of the pipe

getEndpoints

public Endpoint[] getEndpoints()
Specified by:
getEndpoints in interface InputPipe
Returns:
the endpoints for the pipe

send

public java.lang.String send(byte[] message)
                      throws java.io.IOException
Sends a message from the pipe

Specified by:
send in interface OutputPipe
Returns:
the send id for the message (possibly null).
Throws:
java.io.IOException

dataMessageReceived

public void dataMessageReceived(DataMessageEvent event)
Description copied from interface: EndpointMessageListener
Called when the endpoint receives a data message

Specified by:
dataMessageReceived in interface EndpointMessageListener

close

public void close()
           throws java.io.IOException
Description copied from interface: InputPipe
Closes the pipe

Specified by:
close in interface InputPipe
Throws:
java.io.IOException

isClosed

public boolean isClosed()
Specified by:
isClosed in interface InputPipe
Returns:
true if the pipe is closed (i.e. all its underlying socket are closed)