monrovia.server.core
Class ProtocolHandlerImpl

java.lang.Object
  |
  +--monrovia.server.core.ProtocolHandlerImpl
All Implemented Interfaces:
ProtocolHandler

public class ProtocolHandlerImpl
extends java.lang.Object
implements ProtocolHandler

Implementation of the protocol handler.


Inner Class Summary
 class ProtocolHandlerImpl.SocketKey
           
 
Constructor Summary
ProtocolHandlerImpl(PlayerDataImpl pPlayerData, GameDataImpl pGameData)
          Constructor.
 
Method Summary
 int addClient(java.lang.String pName, java.lang.String pPassword, java.lang.String pAddress, int pPort, ServerTcpSender pTcpSender, ServerUdpSender pUdpSender)
          addClient adds pClientName with pClientAddress and pClientPort as well as this clients udpsender and tcp sender to active clients returning an unique pClientID if pClientPassword is correct, if not returns 0, returns 0 also when client is already logged in
 void command(int pClientID, int pCommandID)
          command: pClientID wishes to execute pCommandID
 void command(int pClientID, int pCommandID, int pArg)
          command: pClientID wishes to execute pCommandID with argumet pArg1
 void command(int pClientID, int pCommandID, int pArg1, int pArg2)
          command: pClientID wishes to execute pCommandID with argument pArg1 and pArg2
 void command(int pClientID, int pCommandID, java.lang.String pArg)
          command: pClientID wishes to execute pCommandID with argument pArg1 (string)
 byte[][] getBitmaps(int pClientID)
          getBitmaps returns an array of byte[], each of which is a bitmap
 int getClientID(java.lang.String pAddress, int pPort)
          getClientID returns the clientID identified by pClientAddress and pClientPort.
 Command[] getCommands(int pClientID)
          getCommands returns an array of strings, each of which is the commands text
 int[][] getMap(int pClientID)
          getMap returns the Map of pClientID
 Stat[] getStats(int pClientID)
          getStats return the Stats of pClientID
 int getTurn(int pClientID)
          getTurn returns the ClientID:s turn
 void removeClient(int pClientID)
          removeClient remove pClientID from active clients
 void setTurn(int pClientID, int pTurn)
          setTurn sets ClientID:s turn
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProtocolHandlerImpl

public ProtocolHandlerImpl(PlayerDataImpl pPlayerData,
                           GameDataImpl pGameData)
Constructor.
Method Detail

getMap

public int[][] getMap(int pClientID)
Description copied from interface: ProtocolHandler
getMap returns the Map of pClientID
Specified by:
getMap in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the id of the client
Returns:
the map where the client is now

getCommands

public Command[] getCommands(int pClientID)
Description copied from interface: ProtocolHandler
getCommands returns an array of strings, each of which is the commands text
Specified by:
getCommands in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the id of the client
Returns:
the clients commands

getBitmaps

public byte[][] getBitmaps(int pClientID)
Description copied from interface: ProtocolHandler
getBitmaps returns an array of byte[], each of which is a bitmap
Specified by:
getBitmaps in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the id of the client
Returns:
the bitmaps array

getStats

public Stat[] getStats(int pClientID)
Description copied from interface: ProtocolHandler
getStats return the Stats of pClientID
Specified by:
getStats in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the id of the client
Returns:
the stats of the client

addClient

public int addClient(java.lang.String pName,
                     java.lang.String pPassword,
                     java.lang.String pAddress,
                     int pPort,
                     ServerTcpSender pTcpSender,
                     ServerUdpSender pUdpSender)
Description copied from interface: ProtocolHandler
addClient adds pClientName with pClientAddress and pClientPort as well as this clients udpsender and tcp sender to active clients returning an unique pClientID if pClientPassword is correct, if not returns 0, returns 0 also when client is already logged in
Specified by:
addClient in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientName - the user name of the client
pClientPassword - the clients password
pClientAddress - the ip address of the client
pClientPort - the port of the client
pTcpSender - the tcpsender for this client
pUdpSender - the udpsender for this client
Returns:
the unique client identifier

removeClient

public void removeClient(int pClientID)
Description copied from interface: ProtocolHandler
removeClient remove pClientID from active clients
Specified by:
removeClient in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the clients id

getClientID

public int getClientID(java.lang.String pAddress,
                       int pPort)
Description copied from interface: ProtocolHandler
getClientID returns the clientID identified by pClientAddress and pClientPort. Must return 0 if such a client does not exist.
Specified by:
getClientID in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientAddress - the ip address of the client
the - port of the client
Returns:
the clients already allocated unique id

getTurn

public int getTurn(int pClientID)
Description copied from interface: ProtocolHandler
getTurn returns the ClientID:s turn
Specified by:
getTurn in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the id of the client
Returns:
the turn of this client

setTurn

public void setTurn(int pClientID,
                    int pTurn)
Description copied from interface: ProtocolHandler
setTurn sets ClientID:s turn
Specified by:
setTurn in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the clients id
pTurn - the turn to be set

command

public void command(int pClientID,
                    int pCommandID)
Description copied from interface: ProtocolHandler
command: pClientID wishes to execute pCommandID
Specified by:
command in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the clients id
pCommandID - the id of the command

command

public void command(int pClientID,
                    int pCommandID,
                    int pArg)
Description copied from interface: ProtocolHandler
command: pClientID wishes to execute pCommandID with argumet pArg1
Specified by:
command in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the clients id
pCommandID - the id of the command
pArg1 - the value of the argument

command

public void command(int pClientID,
                    int pCommandID,
                    int pArg1,
                    int pArg2)
Description copied from interface: ProtocolHandler
command: pClientID wishes to execute pCommandID with argument pArg1 and pArg2
Specified by:
command in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the clients id
pCommandID - the id of the command
pArg1 - the value of the first argument
pArg2 - the value of the second argument

command

public void command(int pClientID,
                    int pCommandID,
                    java.lang.String pArg)
Description copied from interface: ProtocolHandler
command: pClientID wishes to execute pCommandID with argument pArg1 (string)
Specified by:
command in interface ProtocolHandler
Following copied from interface: monrovia.protocol.server.ProtocolHandler
Parameters:
pClientID - the clients id
pCommandID - the id of the command
pArg1 - the value of the argument