jfreerails.network
Interface Connection2Server

All Known Implementing Classes:
InetConnection2Server, LocalConnection

public interface Connection2Server

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

Author:
Luke

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

Method Detail

isOpen

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


readFromServer

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

Throws:
java.io.IOException

waitForObjectFromServer

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

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

writeToServer

void writeToServer(FreerailsSerializable object)
                   throws java.io.IOException
Sends the specified object to the server.

Throws:
java.io.IOException

disconnect

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

Throws:
java.io.IOException

flush

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

Throws:
java.io.IOException

getServerDetails

java.lang.String getServerDetails()