jfreerails.network
Interface Connection2Client

All Known Implementing Classes:
InetConnection2Client, LocalConnection

public interface Connection2Client

Defines the methods the server can use to send messages to the client.

Author:
Luke

Method Summary
 void disconnect()
          Disconnect from the client.
 void flush()
          Flush the underlying stream.
 boolean isOpen()
          Returns true if this connection is open.
 FreerailsSerializable[] readFromClient()
          Returns an array containing all the objects read from the client since the last time this method or waitForObjectFromClient() was called, if no objects have been received, it returns an empty array rather than blocking.
 FreerailsSerializable waitForObjectFromClient()
          Returns the next object read from the client, blocking if non is available.
 void writeToClient(FreerailsSerializable object)
          Sends the specified object to the client.
 

Method Detail

isOpen

boolean isOpen()
Returns true if this connection is open.


readFromClient

FreerailsSerializable[] readFromClient()
                                       throws java.io.IOException
Returns an array containing all the objects read from the client since the last time this method or waitForObjectFromClient() was called, if no objects have been received, it returns an empty array rather than blocking.

Throws:
java.io.IOException

waitForObjectFromClient

FreerailsSerializable waitForObjectFromClient()
                                              throws java.io.IOException,
                                                     java.lang.InterruptedException
Returns the next object read from the client, blocking if non is available.

Throws:
java.io.IOException
java.lang.InterruptedException

writeToClient

void writeToClient(FreerailsSerializable object)
                   throws java.io.IOException
Sends the specified object to the client.

Throws:
java.io.IOException

flush

void flush()
           throws java.io.IOException
Flush the underlying stream.

Throws:
java.io.IOException

disconnect

void disconnect()
                throws java.io.IOException
Disconnect from the client. When this method returns, calling isOpen() on this object returns false and calling isOpen() on the corresponding Connection2Server held by the client also returns false.

Throws:
java.io.IOException