net.sf.freecol.server.control
Class InputHandler.CurrentPlayerNetworkRequestHandler

java.lang.Object
  extended by net.sf.freecol.server.control.InputHandler.CurrentPlayerNetworkRequestHandler
All Implemented Interfaces:
InputHandler.NetworkRequestHandler
Enclosing class:
InputHandler

abstract class InputHandler.CurrentPlayerNetworkRequestHandler
extends java.lang.Object
implements InputHandler.NetworkRequestHandler

A network request handler for the current player will automatically return an error ("not your turn") if called by a connection other than that of the currently active player. If no game is active or if the player is unknown the same error is returned.


Constructor Summary
InputHandler.CurrentPlayerNetworkRequestHandler()
           
 
Method Summary
 org.w3c.dom.Element handle(Connection conn, org.w3c.dom.Element element)
          Handle a request represented by an Element and return another Element or null as the answer.
protected abstract  org.w3c.dom.Element handle(Player player, Connection conn, org.w3c.dom.Element element)
          Handle a request for the current player.
private  boolean isCurrentPlayer(Player player)
          Check if a player is the current player.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputHandler.CurrentPlayerNetworkRequestHandler

InputHandler.CurrentPlayerNetworkRequestHandler()
Method Detail

handle

public final org.w3c.dom.Element handle(Connection conn,
                                        org.w3c.dom.Element element)
Description copied from interface: InputHandler.NetworkRequestHandler
Handle a request represented by an Element and return another Element or null as the answer.

Specified by:
handle in interface InputHandler.NetworkRequestHandler
Parameters:
conn - The message's Connection.
element - The root element of the message.
Returns:
reply element, may be null.

isCurrentPlayer

private boolean isCurrentPlayer(Player player)
Check if a player is the current player.

Parameters:
player - The player.
Returns:
true if a game is active and the player is the current one.

handle

protected abstract org.w3c.dom.Element handle(Player player,
                                              Connection conn,
                                              org.w3c.dom.Element element)
Handle a request for the current player.

Parameters:
player - The player.
conn - The connection.
element - The element with the request.
Returns:
answer element, may be null.