gecco.client
Interface Server

All Known Implementing Classes:
ServerAmbassador

public interface Server

This is the interface that represents the server from the client's point of view.

Author:
Andreas Enblom

Method Summary
 void abortAction(long actionId)
          Abort an action that has previously been asked to be executed.
 boolean connect(String host, int port)
          Try to connect to the given host and port.
 void disconnect()
          Disconnects from the server.
 long doAction(int pieceHandle, Action a)
          Execute the given Action and return a unique id of that executing action.
 Set getAvailableRoles()
          After a connection has been established, call this to get the available roles.
 BufferedImage getMap()
          Returns the map of the game.
 boolean joinAsRole(String role)
          Join the game as the given role.
 void startGame()
          Called by the client when it is ready to start receiving game messages from the server.
 

Method Detail

connect

public boolean connect(String host,
                       int port)
Try to connect to the given host and port.
Parameters:
host - Description of Parameter
port - Description of Parameter
Returns:
A boolean indicating if the connection could be established.

disconnect

public void disconnect()
Disconnects from the server.

getAvailableRoles

public Set getAvailableRoles()
After a connection has been established, call this to get the available roles.
Returns:
The AvailableRoles value

joinAsRole

public boolean joinAsRole(String role)
Join the game as the given role.
Parameters:
role - Description of Parameter
Returns:
A boolean indicating if the join was successful.

getMap

public BufferedImage getMap()
Returns the map of the game. This may take some time and the server should call method mapLoadingProgressUpdate of interface Client as more and more of the map is loaded.
Returns:
The Map value

startGame

public void startGame()
Called by the client when it is ready to start receiving game messages from the server.

doAction

public long doAction(int pieceHandle,
                     Action a)
Execute the given Action and return a unique id of that executing action. Make sure the piece does not already exeute an action.
Parameters:
pieceHandle - Description of Parameter
a - Description of Parameter
Returns:
Description of the Returned Value

abortAction

public void abortAction(long actionId)
Abort an action that has previously been asked to be executed.
Parameters:
actionId - Description of Parameter