org.npsnet.xrti
Class MessageChannel

java.lang.Object
  extended byorg.npsnet.xrti.MessageChannel
Direct Known Subclasses:
InternetMessageChannel

public abstract class MessageChannel
extends java.lang.Object

The abstract base class of all message channels. Message channels contain both best-effort (packet-based) and reliable (stream-based) components.

Author:
Andrzej Kapolka

Constructor Summary
MessageChannel()
           
 
Method Summary
abstract  void close()
          Closes this channel.
abstract  java.io.InputStream getInputStream()
          Returns the InputStream corresponding to the reliable component of this channel.
abstract  int getMaximumPacketSize()
          Returns the maximum packet size supported by the best-effort component of this channel.
abstract  java.io.OutputStream getOutputStream()
          Returns the OutputStream corresponding to the reliable component of this channel.
abstract  boolean isClosed()
          Checks whether or not this channel is closed.
abstract  void receivePacket(java.net.DatagramPacket packet)
          Receives a packet through the best-effort component of this channel.
abstract  void sendPacket(java.net.DatagramPacket packet)
          Sends a packet through the best-effort component of this channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageChannel

public MessageChannel()
Method Detail

getMaximumPacketSize

public abstract int getMaximumPacketSize()
Returns the maximum packet size supported by the best-effort component of this channel.

Returns:
the maximum packet size, in bytes

sendPacket

public abstract void sendPacket(java.net.DatagramPacket packet)
                         throws java.io.IOException
Sends a packet through the best-effort component of this channel.

Parameters:
packet - the packet to send
Throws:
java.io.IOException - if an error occurs

receivePacket

public abstract void receivePacket(java.net.DatagramPacket packet)
                            throws java.io.IOException
Receives a packet through the best-effort component of this channel. Blocks until a packet is available.

Parameters:
packet - the object to contain the received packet
Throws:
java.io.IOException - if an error occurs

getInputStream

public abstract java.io.InputStream getInputStream()
                                            throws java.io.IOException
Returns the InputStream corresponding to the reliable component of this channel.

Returns:
this channel's input stream
Throws:
java.io.IOException - in an error occurs

getOutputStream

public abstract java.io.OutputStream getOutputStream()
                                              throws java.io.IOException
Returns the OutputStream corresponding to the reliable component of this channel.

Returns:
this channel's output stream
Throws:
java.io.IOException - if an error occurs

close

public abstract void close()
                    throws java.io.IOException
Closes this channel.

Throws:
java.io.IOException - if an error occurs

isClosed

public abstract boolean isClosed()
Checks whether or not this channel is closed.

Returns:
true if this channel has been closed, false otherwise