jfreerails.network
Class EchoGameServer

java.lang.Object
  extended by jfreerails.network.EchoGameServer
All Implemented Interfaces:
java.lang.Runnable, GameServer, GameModel

public class EchoGameServer
extends java.lang.Object
implements GameServer, java.lang.Runnable

Implementation of GameServer that simply echoes whatever clients send it.

Author:
Luke

Field Summary
private  java.util.Vector<Connection2Client> connections
           
private static java.util.logging.Logger logger
           
private  java.util.LinkedList<FreerailsSerializable> messsages2send
           
private  SynchronizedFlag status
           
 
Constructor Summary
private EchoGameServer()
           
 
Method Summary
 void addConnection(Connection2Client connection)
           
 int countOpenConnections()
           
 void run()
           
(package private)  void sendMessage(FreerailsSerializable m)
           
static EchoGameServer startServer()
          Creates an EchoGameServer, starts it in a new Thread, and waits for its status to change to isOpen before returning.
 void stop()
           
 void update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

connections

private final java.util.Vector<Connection2Client> connections

status

private final SynchronizedFlag status

messsages2send

private final java.util.LinkedList<FreerailsSerializable> messsages2send
Constructor Detail

EchoGameServer

private EchoGameServer()
Method Detail

startServer

public static EchoGameServer startServer()
Creates an EchoGameServer, starts it in a new Thread, and waits for its status to change to isOpen before returning.


addConnection

public void addConnection(Connection2Client connection)
Specified by:
addConnection in interface GameServer

countOpenConnections

public int countOpenConnections()
Specified by:
countOpenConnections in interface GameServer

stop

public void stop()
Specified by:
stop in interface GameServer

run

public void run()
Specified by:
run in interface java.lang.Runnable

sendMessage

void sendMessage(FreerailsSerializable m)

update

public void update()
Specified by:
update in interface GameModel