|
Ver. 20060815 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectServer.Server
public class Server
Reference implementation of the SIMSA Server that contain the abstracted connections for clients and modules. The main server loop handles client and module registration and message routing. 2006-08-15 Kyle Reed
Field Summary | |
---|---|
private boolean |
alive
|
(package private) java.util.HashMap<java.lang.Integer,ClientContainer> |
clientList
|
private java.nio.channels.ServerSocketChannel |
clientPort
|
private java.nio.channels.SelectionKey |
clientPortKey
|
private java.nio.channels.SocketChannel |
incomingChannel
|
private java.nio.channels.SelectionKey |
incomingKey
|
int |
MAX_BUFFER_SIZE
|
(package private) java.util.HashMap<java.lang.Integer,ModuleContainer> |
moduleList
|
private java.nio.channels.ServerSocketChannel |
modulePort
|
private java.nio.channels.SelectionKey |
modulePortKey
|
private java.util.Set<java.nio.channels.SelectionKey> |
selectedKeys
|
private java.util.Iterator<java.nio.channels.SelectionKey> |
selectionKeyIter
|
private java.lang.Thread |
server
|
private java.nio.channels.Selector |
socketListener
|
Constructor Summary | |
---|---|
Server()
Initializes registration lists and starts the main server thread. |
Method Summary | |
---|---|
private void |
getActiveKeys()
Get the set of keys that have incoming data and puts them into a set for processing. |
java.nio.channels.Selector |
getSelector()
|
private boolean |
hasIncoming()
Returns true if there is another key in the Selection set that needs to be processed. |
boolean |
isAlive()
|
void |
kill()
Kills the server by setting the alive boolean value to false, breaking out of main while loop |
void |
killAllModules()
Kills all of the modules on the server. |
java.lang.String |
killClient(int id)
Calls the selfDestruct() method of the ClientContainer to remove the Client with the given ID from the server. |
java.lang.String |
killClientAuth(int id,
int chNum)
Calls the selfDestruct() method of the ClientContainer to remove the Client with the given ID from thse server, this allows modules to pass their Challange key to disconnect themselves. |
java.lang.String |
killModule(int id)
Calls the selfDestruct() method of the ModuleContainer to remove the Module with the given ID from thse server. |
java.lang.String |
killModuleAuth(int id,
int chNum)
Calls the selfDestruct() method of the ModuleContainer to remove the Module with the given ID from thse server, this allows modules to pass their Challange key to disconnect themselves. |
java.lang.String |
listClients()
Returns a formatted string of the loaded client. |
java.lang.String |
listModules()
Returns a formatted string of the loaded modules. |
java.lang.String |
loadModule(java.lang.String mod)
Loads a module (by class name) dynamically to be run in the same VM as the server. |
private boolean |
open()
Returns true if all of the server sockets have been successfully bound to the Selector. |
private void |
processIncoming()
Processes an incoming message from the selector, it will register new clients or call the handleInput() method of the appropriate ConnectionContainer. |
private void |
registerClient()
Adds a client to the client list and assigns it to a new ClientContainer. |
private void |
registerModule()
Adds a module to the module list and assigns it to a new ModuleContainer. |
private void |
removeIncoming()
Removes a client/module from the server by calling the selfDestruct() which will cancel its registration with the Selector and remove itself from the registration lists. |
private void |
run()
The main server loop that listens for incoming messages and processes them. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.nio.channels.Selector socketListener
private java.nio.channels.ServerSocketChannel clientPort
private java.nio.channels.ServerSocketChannel modulePort
private java.nio.channels.SelectionKey clientPortKey
private java.nio.channels.SelectionKey modulePortKey
private java.nio.channels.SelectionKey incomingKey
private java.nio.channels.SocketChannel incomingChannel
private java.util.Set<java.nio.channels.SelectionKey> selectedKeys
private java.util.Iterator<java.nio.channels.SelectionKey> selectionKeyIter
private java.lang.Thread server
private boolean alive
public final int MAX_BUFFER_SIZE
java.util.HashMap<java.lang.Integer,ClientContainer> clientList
java.util.HashMap<java.lang.Integer,ModuleContainer> moduleList
Constructor Detail |
---|
public Server()
Method Detail |
---|
private boolean open()
private void run()
private void getActiveKeys() throws java.lang.Exception
java.lang.Exception
private boolean hasIncoming()
private void processIncoming()
private void removeIncoming()
private void registerModule()
private void registerClient()
public java.nio.channels.Selector getSelector()
public boolean isAlive()
public void kill()
public java.lang.String loadModule(java.lang.String mod)
public java.lang.String listModules()
public java.lang.String killModule(int id)
public java.lang.String killModuleAuth(int id, int chNum)
public void killAllModules()
public java.lang.String listClients()
public java.lang.String killClient(int id)
public java.lang.String killClientAuth(int id, int chNum)
|
Ver. 20060815 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |