JSettlers v1.0.6 API
Built ${date}

soc.server.genericServer
Class Server

java.lang.Object
  extended byjava.lang.Thread
      extended bysoc.server.genericServer.Server
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
SOCServer

public abstract class Server
extends java.lang.Thread
implements java.io.Serializable, java.lang.Cloneable

a general purpose server

Version:
1.5 Original author: Cristian Bogdan Lots of mods by Robert S. Thomas and Jay Budzik This is the real stuff. Server subclasses won't have to care about reading/writing on the net, data consistency among threads, etc.
See Also:
Serialized Form

Field Summary
protected  java.util.Vector conns
          the connections
protected  java.lang.Exception error
           
 java.util.Vector inQueue
           
protected  int numberOfConnections
          total number of connections made
protected  int port
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Server(int port)
          start listening to the given port
 
Method Summary
protected  void addConnection(Connection c)
          add a connection to the system
protected  void broadcast(java.lang.String m)
          broadcast a message
protected  int connectionCount()
           
protected  java.util.Enumeration getConnections()
           
protected  boolean isUp()
           
protected  void leaveConnection(Connection c)
          placeholder for doing things when a connection is closed
protected  void newConnection(Connection c)
          placeholder for doing things when a new connection comes
abstract  void processCommand(java.lang.String str, Connection con)
          DOCUMENT ME!
protected  void removeConnection(Connection c)
          remove a connection from the system
protected  void removeConnectionCleanup(Connection c)
          do cleanup after a remove connection
 void run()
          run method for Server
protected  void serverDown()
          placeholder for doing things when server gets down
 void stopServer()
          The server is being stopped, disconnect all the connections.
 void treat(java.lang.String s, Connection c)
          treat a request from the given connection
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

error

protected java.lang.Exception error

port

protected int port

numberOfConnections

protected int numberOfConnections
total number of connections made


conns

protected java.util.Vector conns
the connections


inQueue

public java.util.Vector inQueue
Constructor Detail

Server

public Server(int port)
start listening to the given port

Method Detail

getConnections

protected java.util.Enumeration getConnections()

connectionCount

protected int connectionCount()

isUp

protected boolean isUp()

run

public void run()
run method for Server

Specified by:
run in interface java.lang.Runnable

treat

public void treat(java.lang.String s,
                  Connection c)
treat a request from the given connection


processCommand

public abstract void processCommand(java.lang.String str,
                                    Connection con)
DOCUMENT ME!

Parameters:
str - DOCUMENT ME!
con - DOCUMENT ME!

serverDown

protected void serverDown()
placeholder for doing things when server gets down


newConnection

protected void newConnection(Connection c)
placeholder for doing things when a new connection comes


leaveConnection

protected void leaveConnection(Connection c)
placeholder for doing things when a connection is closed


stopServer

public void stopServer()
The server is being stopped, disconnect all the connections. Currently nobody calls this.


removeConnection

protected void removeConnection(Connection c)
remove a connection from the system


removeConnectionCleanup

protected void removeConnectionCleanup(Connection c)
do cleanup after a remove connection


addConnection

protected void addConnection(Connection c)
add a connection to the system


broadcast

protected void broadcast(java.lang.String m)
broadcast a message


JSettlers v1.0.6 API
Built ${date}