use of com.faforever.server.game.GameOptionReport in project faf-java-server by FAForever.
the class LegacyRequestTransformer method transform.
@Override
public ClientMessage transform(Map<String, Object> source) {
String command = (String) source.get("command");
LegacyClientMessageType messageType = LegacyClientMessageType.fromString(command);
Requests.verify(messageType != null, ErrorCode.INVALID_COMMAND, command);
switch(messageType) {
case HOST_GAME:
return handleHostGame(source);
case JOIN_GAME:
return new JoinGameRequest(((Number) source.get("uid")).intValue(), (String) source.get("password"));
case ASK_SESSION:
String userAgent = (String) source.get("user_agent");
return LegacySessionRequest.forUserAgent(userAgent);
case SOCIAL_ADD:
return handleSocialAdd(source);
case SOCIAL_REMOVE:
return handleSocialRemove(source);
case LOGIN:
return handleLogin(source);
case GAME_MATCH_MAKING:
return handleMatchMaking(source);
case AVATAR:
return handleAvatar(source);
case GAME_STATE:
return handleGameState(source);
case GAME_OPTION:
List<Object> args = getArgs(source);
return new GameOptionReport((String) args.get(0), args.get(1));
case PLAYER_OPTION:
args = getArgs(source);
return new PlayerOptionReport(Integer.parseInt((String) args.get(0)), (String) args.get(1), args.get(2));
case CLEAR_SLOT:
args = getArgs(source);
return ClearSlotRequest.valueOf((int) args.get(0));
case DESYNC:
return DesyncReport.INSTANCE;
case GAME_MODS:
return handleGameMods(source);
case GAME_RESULT:
return handleGameResult(source);
case OPERATION_COMPLETE:
return handleOperationComplete(source);
case JSON_STATS:
return handleJsonStats(source);
case ENFORCE_RATING:
return PlayerDefeatedReport.INSTANCE;
case TEAMKILL_REPORT:
return handleTeamKillReport(source);
case MUTUAL_DRAW:
return MutuallyAgreedDrawRequest.INSTANCE;
case AI_OPTION:
return handleAiOption(source);
case INITIATE_TEST:
throw new RequestException(ErrorCode.UNSUPPORTED_REQUEST, source);
case ICE_SERVERS:
return IceServersRequest.INSTANCE;
case ICE_MESSAGE:
args = getArgs(source);
return new IceMessage((int) args.get(0), args.get(1));
case RESTORE_GAME_SESSION:
return new RestoreGameSessionRequest((int) source.get("game_id"));
case CREATE_ACCOUNT:
throw new RequestException(ErrorCode.CREATE_ACCOUNT_IS_DEPRECATED);
case ADMIN:
return handleAdminAction(source);
case DISCONNECTED:
return DisconnectedReport.INSTANCE;
case BOTTLENECK:
return BottleneckReport.INSTANCE;
case CHAT:
return handleGameChatMessage((String) getArgs(source).get(0));
case BOTTLENECK_CLEARED:
return BottleneckClearedReport.INSTANCE;
default:
throw new ProgrammingError("Uncovered message type: " + messageType);
}
}
use of com.faforever.server.game.GameOptionReport in project faf-java-server by FAForever.
the class GameServiceActivatorsTest method updateGameOption.
@Test
public void updateGameOption() throws Exception {
instance.updateGameOption(new GameOptionReport("key", "value"), clientConnection.getAuthentication());
verify(gameService).updateGameOption(player, "key", "value");
}
use of com.faforever.server.game.GameOptionReport in project faf-java-server by FAForever.
the class V2ClientMessageTransformerTest method gameOption.
@Test
public void gameOption() throws Exception {
ClientMessage result = instance.transform(write(new GameOptionClientMessage("key", "value")));
assertThat(result, is(new GameOptionReport("key", "value")));
}
use of com.faforever.server.game.GameOptionReport in project faf-java-server by FAForever.
the class LegacyRequestTransformerTest method transformGameOption.
@Test
public void transformGameOption() throws Exception {
GameOptionReport gameOptionReport = (GameOptionReport) instance.transform(ImmutableMap.of(KEY_COMMAND, "GameOption", KEY_ARGS, Arrays.asList("GameSpeed", "normal")));
assertThat(gameOptionReport, is(notNullValue()));
assertThat(gameOptionReport.getKey(), is("GameSpeed"));
assertThat(gameOptionReport.getValue(), is("normal"));
}
Aggregations