* @return ClientState
*/
@Override
public ClientState receiveMessage(ClientMessage message) {
if (message == null) {
LogoutMessage m = new LogoutMessage();
m.setClientId(this.getClient().getClientID());
try {
this.gameQueue.put(new QueueMessage<GameMessage>(m));
} catch (InterruptedException e) {
inGameLogger.error("InterruptedException", e);
}
this.logout();
inGameLogger.info(
"client " + this.getClient()
+ " disconnected in InGameState");
return null;
} else if (message instanceof UpdateDataRequestMessage) {
UpdateDataRequestMessage updateDataRequestMessage =
(UpdateDataRequestMessage) message;
UpdateDataResponseMessage m = new UpdateDataResponseMessage();
m.setResponseType(AuthenticationService.update(
this.getClient().getUserName(),
updateDataRequestMessage.getOldPassword(),
updateDataRequestMessage.getPassword(),
updateDataRequestMessage.getEmail()));
this.getClient().send(m);
return this;
} else if (message instanceof ScoreRequestMessage) {
ScoreRequestMessage requestMessage = (ScoreRequestMessage) message;
ScoreResponseMessage responseMessage =
HighscoreService.getScoreMessage(requestMessage.getPlayerName());
this.getClient().send(responseMessage);
return this;
} else if (message instanceof DeleteRequestMessage) {
DeleteResponseMessage m = new DeleteResponseMessage();
m.setResponseType(AuthenticationService.delete(
this.getClient().getUserName()));
this.getClient().send(m);
return this;
} else if (message instanceof GameMessage) {
try {