org.jscience.net
Class ChatServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.jscience.net.ChatServer
All Implemented Interfaces:
java.lang.Runnable, ConnectionDispatcher, NetConnectionHandler

public class ChatServer
extends java.lang.Thread
implements ConnectionDispatcher, NetConnectionHandler

ChatServer implements a server that handles chat messages that are broadcasted among the active connections to the server.

See Also:
JChat

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String SIGNATURE
          DOCUMENT ME!
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ChatServer(int serverPort, Logger logger)
          Creates a new ChatServer object.
 
Method Summary
 void connectionLost(NetConnection con)
          DOCUMENT ME!
 java.lang.Thread createHandlerThread(NetConnection con)
          DOCUMENT ME!
 NetConnection[] getConnections()
          DOCUMENT ME!
 java.lang.Object getConnectionSignature()
          DOCUMENT ME!
 int getLocalPort()
          returns the port the server is listening on
 Logger getLogger()
          DOCUMENT ME!
 void handleMessage(java.lang.Object message, NetConnection con)
          DOCUMENT ME!
static void main(java.lang.String[] args)
          starts a ChatServer after making some GUI selections
 void run()
          starts the underlying server
 void shutdown()
          DOCUMENT ME!
static void startServerWithGUI(Logger logger)
          uses the org.jscience.net.chat.port property from Settings
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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

SIGNATURE

public static final java.lang.String SIGNATURE
DOCUMENT ME!

See Also:
Constant Field Values
Constructor Detail

ChatServer

public ChatServer(int serverPort,
                  Logger logger)
           throws java.io.IOException
Creates a new ChatServer object.

Parameters:
serverPort - DOCUMENT ME!
logger - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
Method Detail

createHandlerThread

public java.lang.Thread createHandlerThread(NetConnection con)
DOCUMENT ME!

Specified by:
createHandlerThread in interface ConnectionDispatcher
Parameters:
con - DOCUMENT ME!
Returns:
DOCUMENT ME!
See Also:
MessageDelegator

connectionLost

public void connectionLost(NetConnection con)
DOCUMENT ME!

Specified by:
connectionLost in interface NetConnectionHandler
Parameters:
con - DOCUMENT ME!

getConnectionSignature

public java.lang.Object getConnectionSignature()
DOCUMENT ME!

Specified by:
getConnectionSignature in interface ConnectionDispatcher
Returns:
DOCUMENT ME!

handleMessage

public void handleMessage(java.lang.Object message,
                          NetConnection con)
DOCUMENT ME!

Specified by:
handleMessage in interface NetConnectionHandler
Parameters:
message - DOCUMENT ME!
con - DOCUMENT ME!

shutdown

public void shutdown()
DOCUMENT ME!


run

public void run()
starts the underlying server

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getLocalPort

public int getLocalPort()
returns the port the server is listening on

Returns:
DOCUMENT ME!

getConnections

public NetConnection[] getConnections()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getLogger

public Logger getLogger()
DOCUMENT ME!

Returns:
DOCUMENT ME!

startServerWithGUI

public static void startServerWithGUI(Logger logger)
                               throws java.io.IOException
uses the org.jscience.net.chat.port property from Settings

Throws:
java.io.IOException
See Also:
Settings

main

public static void main(java.lang.String[] args)
starts a ChatServer after making some GUI selections

Parameters:
args - DOCUMENT ME!