public class ObserverClientControl extends Object implements IObserverClientControl
Modifier and Type | Field and Description |
---|---|
protected int |
clientId |
protected String |
clientName |
protected de.smarten.tsuro.shared.network.client.ObserverClientToServerConnection |
connection |
protected int |
connectionState |
protected de.smarten.tsuro.shared.gamemodel.GameModel |
gameModel |
Constructor and Description |
---|
ObserverClientControl(ObserverGUIControl observerGuiControl)
Gets and sets the ObserverGuiControl instance, called by class ObserverGUIControl
|
Modifier and Type | Method and Description |
---|---|
void |
connectionResetCallback()
Is called upon a connection reset (i.e.
|
boolean |
disconnect()
Disconnects from the server and returns true if it was successful.
|
void |
finishNotificationCallback() |
void |
gameContinueNotificationCallback() |
void |
gameListResponseCallback(List<de.smarten.tsuro.shared.gamemodel.Game> pGameList)
Is called when a GameListResponse has been received.
|
void |
gamePauseNotificationCallback() |
void |
gameStartNotificationCallback()
Is used when a GameStartNotification has been sent.
|
String |
getClientName()
Returns the name of the client.
|
int |
getConnectionState()
Returns the current connection state,
1 stands for "connected", 0 for "not connected".
|
String |
getNetworkAddress()
Returns the networkAddress of the server the client is connected to
|
ObserverGUIControl |
getObserverGuiControl()
function necessary and used for testing
|
void |
joinGame(int pGameId,
String pPlayerName,
de.smarten.tsuro.shared.gamemodel.Role role)
Sends a GameJoinRequest with the information passed.
|
void |
kickNotificationCallback(List<de.smarten.tsuro.shared.gamemodel.Player> kickedPlayers) |
void |
processingRequestReplyCallback(de.smarten.tsuro.shared.gamemodel.JoinResponse response,
int clientId) |
void |
register(String pNetworkAddress)
Is called when a user entered a network address and clicked register.
|
void |
requestGameList()
Forwards the request for a GameList to the ObserverClientToServerConnection
|
void |
setError(String pError,
String errorSource)
Forwards an error message to the GUIControl and the source of the error, e.g.
|
void |
setMessage(String pMessage,
String messageSource)
Forwards a message to the GUIControl and the source of the message, e.g.
|
void |
startGame(de.smarten.tsuro.shared.gamemodel.GameModel gameModel)
Starts a game by setting the game model and telling the GUI to start displaying the game.
|
void |
turnNotificationCallback(boolean placeToken)
The method is needed for the PlayerClient but not for the ObserverClient.
|
protected int connectionState
protected int clientId
protected String clientName
protected de.smarten.tsuro.shared.gamemodel.GameModel gameModel
protected de.smarten.tsuro.shared.network.client.ObserverClientToServerConnection connection
public ObserverClientControl(ObserverGUIControl observerGuiControl)
observerGuiControl
- an object of the class ObserverGUIControlpublic void register(String pNetworkAddress)
IObserverClientControl
register
in interface IObserverClientControl
pNetworkAddress
- The network address to be connected topublic void startGame(de.smarten.tsuro.shared.gamemodel.GameModel gameModel)
IObserverClientControl
startGame
in interface IObserverClientControl
startGame
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
gameModel
- The game model linked to the game to be startedpublic boolean disconnect()
IObserverClientControl
disconnect
in interface IObserverClientControl
public void setMessage(String pMessage, String messageSource)
IObserverClientControl
setMessage
in interface IObserverClientControl
pMessage
- the message to be displayedmessageSource
- source where the message came frompublic void setError(String pError, String errorSource)
IObserverClientControl
setError
in interface IObserverClientControl
pError
- the error message to be displayederrorSource
- the source where the error occuredpublic String getNetworkAddress()
IObserverClientControl
getNetworkAddress
in interface IObserverClientControl
public int getConnectionState()
IObserverClientControl
getConnectionState
in interface IObserverClientControl
public String getClientName()
IObserverClientControl
getClientName
in interface IObserverClientControl
public void joinGame(int pGameId, String pPlayerName, de.smarten.tsuro.shared.gamemodel.Role role)
IObserverClientControl
joinGame
in interface IObserverClientControl
pGameId
- the id of the game to be joined (-1 for the pool)pPlayerName
- the name the client would like to takepublic void requestGameList()
IObserverClientControl
requestGameList
in interface IObserverClientControl
public void gameListResponseCallback(List<de.smarten.tsuro.shared.gamemodel.Game> pGameList)
IObserverClientControl
gameListResponseCallback
in interface IObserverClientControl
gameListResponseCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
pGameList
- The list to be displayed by the GUIpublic void gameStartNotificationCallback()
IObserverClientControl
gameStartNotificationCallback
in interface IObserverClientControl
gameStartNotificationCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
public void processingRequestReplyCallback(de.smarten.tsuro.shared.gamemodel.JoinResponse response, int clientId)
processingRequestReplyCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
public void kickNotificationCallback(List<de.smarten.tsuro.shared.gamemodel.Player> kickedPlayers)
kickNotificationCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
public void gamePauseNotificationCallback()
gamePauseNotificationCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
public void gameContinueNotificationCallback()
gameContinueNotificationCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
public void finishNotificationCallback()
finishNotificationCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
public void turnNotificationCallback(boolean placeToken)
IObserverClientControl
turnNotificationCallback
in interface IObserverClientControl
turnNotificationCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
placeToken
- boolean variable if the token or a tile has to be setpublic ObserverGUIControl getObserverGuiControl()
public void connectionResetCallback()
IObserverClientControl
connectionResetCallback
in interface IObserverClientControl
connectionResetCallback
in interface de.smarten.tsuro.shared.network.client.IClientToServerConnectionCallable
Copyright © 2017 smarTen. All rights reserved.