|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
com.antelmann.net.ChatServer
public class ChatServer
ChatServer implements a server that handles chat messages that are broadcasted among the active connections to the server.
JChat| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static Handshake |
HANDSHAKE
|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
ChatServer(int serverPort,
Logger logger)
|
|
| Method Summary | |
|---|---|
void |
connectionLost(NetConnection con)
called when a connection caused an IOException during reading or writing; the connection may not have been closed at this point. |
SocketConnection |
createConnection(Socket socket)
produces a NetConnection based on the given socket. |
MessageDelegator |
createDispatcher(NetConnection con,
NetConnectionHandler handler)
responsible for creating the delegator based on the created connection and the associated handler |
NetConnectionHandler |
createHandler(NetConnection con)
produces a NetConnectionHandler which will be started in a new Thread (created by the NetConnectionServer's ThreadFactory) to handle the given NetConnection and listens to messages. |
NetConnection[] |
getConnections()
|
Handshake |
getHandshake()
returns a signature object used to identify the desired connection type handled by this ConnectionDispatcher object |
int |
getLocalPort()
returns the port the server is listening on |
Logger |
getLogger()
|
void |
handleMessage(Object message,
NetConnection con)
called when a message is received by the given NetConnection object |
static void |
main(String[] args)
starts a ChatServer after making some GUI selections |
void |
run()
starts the underlying server |
void |
shutdown()
|
static void |
startServerWithGUI(Logger logger)
uses the com.antelmann.net.chat.port property from Settings |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, 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 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Handshake HANDSHAKE
| Constructor Detail |
|---|
public ChatServer(int serverPort,
Logger logger)
throws IOException
IOException| Method Detail |
|---|
public SocketConnection createConnection(Socket socket)
throws IOException
ConnectionDispatcher
createConnection in interface ConnectionDispatcherIOExceptionSocketConnection.createServerConnection(Socket, Handshake)public void connectionLost(NetConnection con)
NetConnectionHandler
connectionLost in interface NetConnectionHandlerpublic Handshake getHandshake()
ConnectionDispatcher
getHandshake in interface ConnectionDispatcherpublic NetConnectionHandler createHandler(NetConnection con)
ConnectionDispatcher
createHandler in interface ConnectionDispatcherMessageDelegator
public MessageDelegator createDispatcher(NetConnection con,
NetConnectionHandler handler)
ConnectionDispatcher
createDispatcher in interface ConnectionDispatcher
public void handleMessage(Object message,
NetConnection con)
NetConnectionHandler
handleMessage in interface NetConnectionHandlerpublic void shutdown()
public void run()
run in interface Runnablerun in class Threadpublic int getLocalPort()
public NetConnection[] getConnections()
public Logger getLogger()
public static void startServerWithGUI(Logger logger)
throws IOException
IOExceptionSettingspublic static void main(String[] args)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||