Search in sources :

Example 11 with ClientMessage

use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.

the class V2ClientMessageTransformerTest method gameDesync.

@Test
public void gameDesync() throws Exception {
    ClientMessage result = instance.transform(write(new GameDesyncClientMessage()));
    assertThat(result, is(DesyncReport.INSTANCE));
}
Also used : ClientMessage(com.faforever.server.common.ClientMessage) Test(org.junit.Test)

Example 12 with ClientMessage

use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.

the class V2ClientMessageTransformerTest method gameState.

@Test
public void gameState() throws Exception {
    ClientMessage result = instance.transform(write(new GameStateClientMessage(PlayerGameState.LAUNCHING)));
    assertThat(result, is(new GameStateReport(PlayerGameState.LAUNCHING)));
}
Also used : ClientMessage(com.faforever.server.common.ClientMessage) GameStateReport(com.faforever.server.game.GameStateReport) Test(org.junit.Test)

Example 13 with ClientMessage

use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.

the class V2ClientMessageTransformer method transform.

@Override
@SneakyThrows
public ClientMessage transform(String source) {
    try {
        V2ClientMessageWrapper wrapper = objectMapper.readValue(source, V2ClientMessageWrapper.class);
        V2ClientMessage message = wrapper.getData();
        Requests.verify(message != null, ErrorCode.UNSUPPORTED_REQUEST, source);
        Method mappingMethod = mapperMethods.get(message.getClass());
        Requests.verify(mappingMethod != null, ErrorCode.UNSUPPORTED_REQUEST, source);
        return (ClientMessage) mappingMethod.invoke(v2ClientMessageMapper, message);
    } catch (JsonMappingException e) {
        throw new RequestException(e, ErrorCode.UNSUPPORTED_REQUEST, source, e.getMessage());
    }
}
Also used : JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Method(java.lang.reflect.Method) ClientMessage(com.faforever.server.common.ClientMessage) RequestException(com.faforever.server.error.RequestException) SneakyThrows(lombok.SneakyThrows)

Example 14 with ClientMessage

use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.

the class V2ClientMessageTransformerTest method playerOption.

@Test
public void playerOption() throws Exception {
    ClientMessage result = instance.transform(write(new PlayerOptionClientMessage(123, "key", "value")));
    assertThat(result, is(new PlayerOptionReport(123, "key", "value")));
}
Also used : PlayerOptionReport(com.faforever.server.game.PlayerOptionReport) ClientMessage(com.faforever.server.common.ClientMessage) Test(org.junit.Test)

Example 15 with ClientMessage

use of com.faforever.server.common.ClientMessage in project faf-java-server by FAForever.

the class V2ClientMessageTransformerTest method armyOutcome.

@Test
public void armyOutcome() throws Exception {
    ClientMessage result = instance.transform(write(new ArmyOutcomeClientMessage(1, Outcome.DEFEAT)));
    assertThat(result, is(ArmyOutcomeReport.valueOf(1, Outcome.DEFEAT)));
}
Also used : ClientMessage(com.faforever.server.common.ClientMessage) Test(org.junit.Test)

Aggregations

ClientMessage (com.faforever.server.common.ClientMessage)27 Test (org.junit.Test)26 SelectAvatarRequest (com.faforever.server.avatar.SelectAvatarRequest)1 BroadcastRequest (com.faforever.server.client.BroadcastRequest)1 LoginRequest (com.faforever.server.client.LoginRequest)1 CoopMissionCompletedReport (com.faforever.server.coop.CoopMissionCompletedReport)1 RequestException (com.faforever.server.error.RequestException)1 AiOptionReport (com.faforever.server.game.AiOptionReport)1 ArmyScoreReport (com.faforever.server.game.ArmyScoreReport)1 DisconnectPeerRequest (com.faforever.server.game.DisconnectPeerRequest)1 GameChatMessageReport (com.faforever.server.game.GameChatMessageReport)1 GameModsReport (com.faforever.server.game.GameModsReport)1 GameOptionReport (com.faforever.server.game.GameOptionReport)1 GameStateReport (com.faforever.server.game.GameStateReport)1 HostGameRequest (com.faforever.server.game.HostGameRequest)1 JoinGameRequest (com.faforever.server.game.JoinGameRequest)1 PlayerOptionReport (com.faforever.server.game.PlayerOptionReport)1 TeamKillReport (com.faforever.server.game.TeamKillReport)1 IceMessage (com.faforever.server.ice.IceMessage)1 RestoreGameSessionRequest (com.faforever.server.integration.legacy.transformer.RestoreGameSessionRequest)1