org.eclipse.palamedes.gdl.connection
Class PlayerServer

java.lang.Object
  extended by org.eclipse.palamedes.gdl.connection.NanoHTTPD
      extended by org.eclipse.palamedes.gdl.connection.PlayerServer

public class PlayerServer
extends NanoHTTPD


Field Summary
protected static boolean DEFAULT_MODE
           
protected static int DEFAULT_PORT
           
protected  Player player
          Stores the player of this server
protected  int port
           
protected  boolean slaveMode
           
 
Fields inherited from class org.eclipse.palamedes.gdl.connection.NanoHTTPD
MIME_DEFAULT_BINARY, MIME_HTML, MIME_PLAINTEXT, myFileDir, server_thread
 
Constructor Summary
PlayerServer(Player player, java.util.Map<java.lang.String,java.lang.String> options)
           
 
Method Summary
static java.util.Map<java.lang.String,java.lang.String> getOptions(java.lang.String[] args)
          This method creates and returns the option map.
protected static int getPort(java.util.Map<java.lang.String,java.lang.String> argumentMap)
          This method extracts the port number out of the argument map.
static void main(java.lang.String[] args)
          starts the game player and waits for messages from the game master
Command line options: [port] slave
 Response serve(java.lang.String uri, java.lang.String method, java.util.Properties header, java.util.Properties parms, java.lang.String data)
          Override this to customize the server.
protected  void setOptions(java.util.Map<java.lang.String,java.lang.String> options)
          This method is a hook to setup any relevant commandline option within the player server or player.
 void waitForExit()
          wait for server thread to exit
 
Methods inherited from class org.eclipse.palamedes.gdl.connection.NanoHTTPD
serveFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

protected static int DEFAULT_PORT

DEFAULT_MODE

protected static boolean DEFAULT_MODE

player

protected Player player
Stores the player of this server


port

protected int port

slaveMode

protected boolean slaveMode
Constructor Detail

PlayerServer

public PlayerServer(Player player,
                    java.util.Map<java.lang.String,java.lang.String> options)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

serve

public Response serve(java.lang.String uri,
                      java.lang.String method,
                      java.util.Properties header,
                      java.util.Properties parms,
                      java.lang.String data)
Description copied from class: NanoHTTPD
Override this to customize the server.

(By default, this delegates to serveFile() and allows directory listing.)

Overrides:
serve in class NanoHTTPD
Parameters:
uri - Percent-decoded URI without parameters, for example "/index.cgi"
method - "GET", "POST" etc.
header - Header entries, percent decoded
parms - Parsed, percent decoded parameters from URI and, in case of POST, data.
Returns:
HTTP response, see class Response for details

waitForExit

public void waitForExit()
wait for server thread to exit


setOptions

protected void setOptions(java.util.Map<java.lang.String,java.lang.String> options)
This method is a hook to setup any relevant commandline option within the player server or player.

Parameters:
options -

getOptions

public static java.util.Map<java.lang.String,java.lang.String> getOptions(java.lang.String[] args)
This method creates and returns the option map.


getPort

protected static int getPort(java.util.Map<java.lang.String,java.lang.String> argumentMap)
This method extracts the port number out of the argument map.

Parameters:
argumentMap -

main

public static void main(java.lang.String[] args)
starts the game player and waits for messages from the game master
Command line options: [port] slave