|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectglassfrog.server.Server.ServerConnectionHandler
public class Server.ServerConnectionHandler
A class used to handle incoming connections to the server. This class is used to parse the request arguments to the server such as the requests to add and kill rooms, info requests from rooms and other information regarding the state of the server
Field Summary | |
---|---|
private java.io.BufferedReader |
br
|
private java.lang.Object |
lock
|
private java.io.PrintWriter |
pw
|
private java.net.Socket |
socket
|
private int |
TIMEOUT
|
Constructor Summary | |
---|---|
Server.ServerConnectionHandler(java.net.Socket socket)
The ServerConnectionHandler takes the socket that the ServerSocket gets from an accepted connection. |
Method Summary | |
---|---|
private void |
autoConnect(java.lang.String key)
The auto connect routine for a key value and the online client |
private java.lang.String |
getStatus(java.lang.String roomName)
Get the status for a given room name, or for all the rooms if ALL is specified as the argument. |
private java.lang.String |
getUsage(java.lang.String helpRequest)
|
private void |
handleRequest()
Handles any request made from a connection to the server |
private void |
kill(java.lang.String roomName)
Shudown a specific room or all of the rooms if the ALL argument is passed in as the roomName |
private void |
killServer()
Closes the current connection and sets the alive boolean to false telling the server to stop listening for incoming connections and to exit |
private java.lang.String |
list()
Get a list of all the Running, Finished, Disconnected and Errored Rooms |
private void |
parseConfigFile(java.lang.String path,
java.lang.String name,
int seed)
Parse the given config file. |
void |
run()
A wrapper to handle the requests from the server so that this can be invoked in a thread |
private int |
startRoom(java.lang.String name,
int hands,
java.lang.String gamedefPath,
int seed)
Start up a new room |
private java.lang.String |
validateKey(java.lang.String key)
Lookup a seed and username from a specific key value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.io.PrintWriter pw
private java.io.BufferedReader br
private java.net.Socket socket
private final int TIMEOUT
private final java.lang.Object lock
Constructor Detail |
---|
public Server.ServerConnectionHandler(java.net.Socket socket) throws java.io.IOException
socket
- A Socket passed in from the server
java.io.IOException
- Any exceptions from the socket handleingMethod Detail |
---|
public void run()
run
in interface java.lang.Runnable
private void handleRequest() throws java.io.IOException, java.net.SocketTimeoutException, java.lang.InterruptedException
java.io.IOException
java.socket.SocketTimeoutException
java.net.SocketTimeoutException
java.lang.InterruptedException
private java.lang.String getUsage(java.lang.String helpRequest)
private void autoConnect(java.lang.String key) throws java.lang.NullPointerException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXParseException, org.xml.sax.SAXException, java.io.IOException, java.lang.InterruptedException
key
-
java.lang.NullPointerException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXParseException
org.xml.sax.SAXException
java.io.IOException
java.lang.InterruptedException
private java.lang.String validateKey(java.lang.String key) throws java.lang.NullPointerException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXParseException, org.xml.sax.SAXException, java.io.IOException
key
- a String used for the key value pair of the seed
java.lang.NullPointerException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXParseException
org.xml.sax.SAXException
java.io.IOException
private java.lang.String getStatus(java.lang.String roomName)
roomName
- A name for the specific status
private java.lang.String list()
private void parseConfigFile(java.lang.String path, java.lang.String name, int seed) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXParseException, org.xml.sax.SAXException, java.io.IOException, java.lang.InterruptedException
path
- A path to a given XML config filename
- A @String for the name of the room, blank to use name
specified in the config fileseed
- Specify the seed. Use -1 to grab from config file
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXParseException
org.xml.sax.SAXException
java.io.IOException
java.lang.InterruptedException
private void kill(java.lang.String roomName) throws java.io.IOException
roomName
- The name of the room to kill
java.io.IOException
private void killServer() throws java.io.IOException
java.io.IOException
private int startRoom(java.lang.String name, int hands, java.lang.String gamedefPath, int seed) throws java.io.IOException, java.lang.InterruptedException
name
- The name of the room to starthands
- number of hands to platgamedefPath
- the path to the gamedef fileseed
- the seed for the cards
java.io.IOException
java.lang.InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |