public class LobbyClient extends XStreamClient implements IPollsHistory
This class is used to handle all communication with a server. - It is used in a client (e.g. the java simple client). - It is also used to represent observer-threads started by the server which connect to the server. The server always has a Client object for every LobbyClient representing the client on the server-side.
public static java.lang.String DEFAULT_HOST
public LobbyClient()
public LobbyClient(java.lang.String host, int port)
protected void onObject(ProtocolMessage o)
protected void onGamePrepared(GamePreparedResponse response)
public void authenticate(java.lang.String password)
public RequestResult<sc.protocol.responses.GamePreparedResponse> prepareGameAndWait(java.lang.String gameType)
public RequestResult<sc.protocol.responses.GamePreparedResponse> prepareGameAndWait(PrepareGameRequest request)
public void prepareGame(java.lang.String gameType)
public void prepareGame(java.lang.String gameType, boolean startPaused)
protected void onCustomObject(java.lang.Object o)
protected void onNewState(java.lang.String roomId, IGameState state)
protected void onRoomMessage(java.lang.String roomId, ProtocolMessage data)
protected void onError(java.lang.String roomId, ProtocolErrorMessage error)
public void sendMessageToRoom(java.lang.String roomId, ProtocolMessage o)
public void joinPreparedGame(java.lang.String reservation)
used in server
reservation
- reservation IDpublic void joinRoomRequest(java.lang.String gameType)
currently not used in server
gameType
- GameIDprotected void request(ProtocolMessage request, java.lang.Class<? extends sc.protocol.responses.ProtocolMessage> response, IRequestResult handler)
used in server
request
- ProtocolMessage which contains the requestresponse
- Response class to be createdhandler
- Handler for the requestsprotected RequestResult<T> blockingRequest(ProtocolMessage request, java.lang.Class<? extends sc.protocol.responses.ProtocolMessage> response)
public void addListener(ILobbyClientListener listener)
public void removeListener(ILobbyClientListener listener)
public IControllableGame observeAndControl(java.lang.String roomId)
Takes control of the game in the given room and pauses it.
public IControllableGame observeAndControl(java.lang.String roomId, boolean isPaused)
Takes control of the game in the given room.
isPaused
- whether the game to observe is already paused.public ObservingClient observe(java.lang.String roomId)
public ObservingClient observe(java.lang.String roomId, boolean isPaused)
public void addListener(IHistoryListener listener)
public void removeListener(IHistoryListener listener)
public void addListener(IAdministrativeListener listener)
public void removeListener(IAdministrativeListener listener)
public void freeReservation(java.lang.String reservation)