jfreerails.network
Class InetConnection2Server

java.lang.Object
  extended by jfreerails.network.AbstractInetConnection
      extended by jfreerails.network.InetConnection2Server
All Implemented Interfaces:
java.lang.Runnable, Connection2Server

public class InetConnection2Server
extends AbstractInetConnection
implements Connection2Server

Lets a client send messages to the server over the Internet.

Author:
Luke

Field Summary
(package private)  java.lang.String serverDetails
           
 
Constructor Summary
InetConnection2Server(java.lang.String ip, int port)
           
 
Method Summary
 java.lang.String getServerDetails()
           
(package private)  java.lang.String getThreadName()
           
 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.
 
Methods inherited from class jfreerails.network.AbstractInetConnection
disconnect, flush, isOpen, read, run, send, setTimeOut, waitForObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jfreerails.network.Connection2Server
disconnect, flush, isOpen
 

Field Detail

serverDetails

final java.lang.String serverDetails
Constructor Detail

InetConnection2Server

public InetConnection2Server(java.lang.String ip,
                             int port)
                      throws java.io.IOException
Throws:
java.io.IOException
Method Detail

readFromServer

public FreerailsSerializable[] readFromServer()
                                       throws java.io.IOException
Description copied from interface: Connection2Server
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.

Specified by:
readFromServer in interface Connection2Server
Throws:
java.io.IOException

waitForObjectFromServer

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

Specified by:
waitForObjectFromServer in interface Connection2Server
Throws:
java.io.IOException
java.lang.InterruptedException

writeToServer

public void writeToServer(FreerailsSerializable object)
                   throws java.io.IOException
Description copied from interface: Connection2Server
Sends the specified object to the server.

Specified by:
writeToServer in interface Connection2Server
Throws:
java.io.IOException

getThreadName

java.lang.String getThreadName()
Specified by:
getThreadName in class AbstractInetConnection

getServerDetails

public java.lang.String getServerDetails()
Specified by:
getServerDetails in interface Connection2Server