com.asdf.client
Interface MessageHandler

All Known Implementing Classes:
GameController, HelloGame, LobbyController, PokerGameController, TexasGameController

public interface MessageHandler

This interface is used by client program to define the communication interface that ConnectionHandler uses to pass messages received from server to Lobby and to GameControllers started from the lobby. Messages are passed through this interface according to implementing objects sessionID. If you wish to know more about the messaging protocol used, please see protocol.xsd schema file in protocols directory for further details and additional comments for different components in the message.

Author:
asdf

Method Summary
 ConnectionHandler getConnectionHandler()
          Returns the ConnectionHandler used by implementing class.
 long getID()
          Returns the sessionID of this MessageHandler.
 void handleRequest(Request req)
          Handles a Request sent by the server.
 void handleResponse(Response rsp)
          Handles a Response sent by the server.
 void handleStateUpdate(StateUpdate stateUp)
          Handles StateUpdates sent by server.
 void setConnectionHandler(ConnectionHandler connection)
          Sets the ConnectionHandler which passes messages to the implementing class trough this interfaces methods.
 void setID(long id)
          Sets a sessionID for this MessageHandler.
 

Method Detail

handleResponse

void handleResponse(Response rsp)
Handles a Response sent by the server. You may wish to leave this method as a stub in your implementation if you are not interested in receiving this kind of messages.

Parameters:
rsp - Response sent by server. Response is an object generated from XML message using JAXB.

handleRequest

void handleRequest(Request req)
Handles a Request sent by the server. You may wish to leave this method as a stub in your implementation if you are not interested in receiving this kind of messages.

Parameters:
req - Request sent by server. Request is an object generated from XML message using JAXB.

handleStateUpdate

void handleStateUpdate(StateUpdate stateUp)
Handles StateUpdates sent by server. You may wish to leave this method as a stub in your implementation if you are not interested in receiving this kind of messages.

Parameters:
stateUp - StateUpdate sent by server. StateUpdate is an object generated from XML message using JAXB.

setConnectionHandler

void setConnectionHandler(ConnectionHandler connection)
Sets the ConnectionHandler which passes messages to the implementing class trough this interfaces methods. Also ConnectionHandler passed down by this method can be used to send messages by calling it through getConnectionHandler() method.

Parameters:
connection - ConnectionHandler to be used.

getConnectionHandler

ConnectionHandler getConnectionHandler()
Returns the ConnectionHandler used by implementing class. When you want to send messages to server, use this method to get the associated ConnectionHandler and call its send -methods.

Returns:
ConnectionHandler used by the implementing class.

getID

long getID()
Returns the sessionID of this MessageHandler.

Returns:
SessionID of this MessageHandler.

setID

void setID(long id)
Sets a sessionID for this MessageHandler.

Parameters:
id - Semi-Unique sessionID.