|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
jhomenet.shell.server.Server
public abstract class Server
A generic server. Servers will listen on some system resource for connection requests. When someone attempts to login, the server spins off a session to handle that login. Servers are designed to be multi-threaded, allowing multiple simultaneous connections.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected boolean |
pauseServer
Flag used to pause and restart the server |
protected java.util.ArrayList<Session> |
sessions
List of sessions created by this server. |
protected boolean |
shutdown
Stops this server when set to true. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
protected |
Server(SystemInterface systemInterface)
Initializes the server and creates the list of sessions (initially empty). |
| Method Summary | |
|---|---|
protected abstract Session |
acceptNewSession()
Waits for a connection request. |
void |
broadcast(java.lang.String sendThis)
Cycles through the list of know sessions, sending the specified message. |
protected void |
checkForNewSessions()
Listens for connection requests. |
protected abstract void |
closeAllPorts()
Cleans up any system resources held by this server. |
java.lang.String[] |
getConnectedUsers()
Gets an array of the names of all of the users that are currently connected to this server. |
SystemInterface |
getSystemInterface()
|
void |
pauseServer()
Pause the server. |
void |
resumeServer()
Resume the server. |
void |
run()
Starts the server. |
void |
sessionEnded(Session session)
Notifies this server that a particular session is ending. |
void |
shutDown()
Requests that the server stop taking connections and terminate any current sessions. |
| 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 |
|---|
protected java.util.ArrayList<Session> sessions
protected boolean shutdown
protected boolean pauseServer
| Constructor Detail |
|---|
protected Server(SystemInterface systemInterface)
| Method Detail |
|---|
public SystemInterface getSystemInterface()
public void pauseServer()
public void resumeServer()
public void run()
shutdown field is set to
true.
run in interface java.lang.Runnablerun in class java.lang.Threadprotected void checkForNewSessions()
protected abstract Session acceptNewSession()
public void shutDown()
throws java.io.IOException
java.io.IOExceptionpublic void sessionEnded(Session session)
session - the session that has terminatedpublic java.lang.String[] getConnectedUsers()
public void broadcast(java.lang.String sendThis)
sendThis - message to send to all sessions
protected abstract void closeAllPorts()
throws java.io.IOException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||