diff --git a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyApi.kt b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyApi.kt index eca1780e..4ba93bdb 100644 --- a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyApi.kt +++ b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyApi.kt @@ -42,12 +42,12 @@ interface LobbyProtocolMessage { JsonSubTypes.Type(value = AcceptInviteToPartyRequest::class, name = "accept_party_invite"), JsonSubTypes.Type(value = KickPlayerFromPartyRequest::class, name = "kick_player_from_party"), JsonSubTypes.Type(value = LeavePartyRequest::class, name = "leave_party"), - JsonSubTypes.Type(value = ReadyPartyRequest::class, name = "ready_party"), JsonSubTypes.Type(value = UnreadyPartyRequest::class, name = "unready_party"), JsonSubTypes.Type(value = SelectPartyFactionsRequest::class, name = "set_party_factions"), JsonSubTypes.Type(value = GameMatchmakingRequest::class, name = "game_matchmaking"), JsonSubTypes.Type(value = MatchmakerInfoRequest::class, name = "matchmaker_info"), JsonSubTypes.Type(value = AuthenticateRequest::class, name = "auth"), + JsonSubTypes.Type(value = IsReadyResponse::class, name = "is_ready_response"), // GPG Client Messages not directly instantiated they are only forwarded from the game so are serialized directly ) interface ClientMessage : LobbyProtocolMessage @@ -82,6 +82,7 @@ interface ClientMessage : LobbyProtocolMessage JsonSubTypes.Type(value = ConnectToPeerGpgCommand::class, name = "ConnectToPeer"), JsonSubTypes.Type(value = IceMsgGpgCommand::class, name = "IceMsg"), JsonSubTypes.Type(value = DisconnectFromPeerGpgCommand::class, name = "DisconnectFromPeer"), + JsonSubTypes.Type(value = IsReadyRequest::class, name = "is_ready"), ) interface ServerMessage : LobbyProtocolMessage diff --git a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt index ace6e8ad..8b49c280 100644 --- a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt +++ b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/FafLobbyClient.kt @@ -370,6 +370,8 @@ class FafLobbyClient( .flatMapIterable { it.avatarList } ) + override fun sendReady(requestId: String) = send(IsReadyResponse(requestId)) + override fun requestMatchmakerInfo() = send(MatchmakerInfoRequest()) override fun gameMatchmaking(queueName: String, state: MatchmakerState) = @@ -381,8 +383,6 @@ class FafLobbyClient( override fun kickPlayerFromParty(playerId: Int) = send(KickPlayerFromPartyRequest(playerId)) - override fun readyParty() = send(ReadyPartyRequest()) - override fun unreadyParty() = send(UnreadyPartyRequest()) override fun leaveParty() = send(LeavePartyRequest()) diff --git a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/GameApi.kt b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/GameApi.kt index 0a8b005c..c8064a8a 100644 --- a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/GameApi.kt +++ b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/GameApi.kt @@ -82,6 +82,9 @@ enum class GameType { @JsonProperty("custom") CUSTOM, + @JsonProperty("tournament") + TOURNAMENT, + @JsonProperty("matchmaker") MATCHMAKER, @@ -183,7 +186,7 @@ data class GameLaunchResponse( * Technical name of the leaderboard to select ratings to be shown */ @JsonProperty("rating_type") - val leaderboard: String, + val leaderboard: String?, val args: List, @JsonProperty("mapname") diff --git a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/MatchmakerApi.kt b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/MatchmakerApi.kt index c937350f..b08236da 100644 --- a/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/MatchmakerApi.kt +++ b/faf-commons-lobby/src/main/kotlin/com/faforever/commons/lobby/MatchmakerApi.kt @@ -21,13 +21,14 @@ interface MatchmakerApi { fun kickPlayerFromParty(playerId: Int) - fun readyParty() - fun unreadyParty() fun leaveParty() fun setPartyFactions(factions: Set) + + fun sendReady(requestId: String) + } @@ -105,10 +106,35 @@ data class SearchInfo( ) : ServerMessage + +/** + * Server asked if the client is ready for a gw or tournament game + */ +data class IsReadyRequest( + @JsonProperty("game_name") + val gameName: String, + @JsonProperty("featured_mod") + val featuredMod: String, + @JsonProperty("response_time_seconds") + val responseTimeSeconds: Int, + @JsonProperty("request_id") + val requestId: String, +) : ServerMessage + + // *********************** // *** CLIENT MESSAGES *** // *********************** + +/** + * Client answers if the client is ready for a gw or tournament game + */ +internal data class IsReadyResponse( + @JsonProperty("request_id") + val requestId: String, +) : ClientMessage + internal data class GameMatchmakingRequest( @JsonProperty("queue_name") val queueName: String, @@ -130,8 +156,6 @@ internal data class KickPlayerFromPartyRequest( val playerId: Int ) : ClientMessage -internal class ReadyPartyRequest : ClientMessage - internal class UnreadyPartyRequest : ClientMessage internal class LeavePartyRequest : ClientMessage diff --git a/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/ClientMessageTest.kt b/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/ClientMessageTest.kt index e26897e7..916d7df2 100644 --- a/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/ClientMessageTest.kt +++ b/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/ClientMessageTest.kt @@ -198,14 +198,6 @@ class ClientMessageTest { objectMapper.writeValueAsString(LeavePartyRequest()), true) } - @Test - fun serializeReadyPartyRequest() { - JSONAssert.assertEquals(""" - {"command":"ready_party"} - """, - objectMapper.writeValueAsString(ReadyPartyRequest()), true) - } - @Test fun serializeUnreadyPartyRequest() { JSONAssert.assertEquals(""" diff --git a/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/LobbyClientTest.kt b/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/LobbyClientTest.kt index 6621f1e5..a884cd0e 100644 --- a/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/LobbyClientTest.kt +++ b/faf-commons-lobby/src/test/kotlin/com/faforever/commons/lobby/LobbyClientTest.kt @@ -396,18 +396,6 @@ class LobbyClientTest { stepVerifier.verify(verificationDuration) } - @Test - fun testReadyParty() { - val stepVerifier = StepVerifier.create(serverMessagesReceived.take(1)) - .assertNext { assertCommandMatch(it, ReadyPartyRequest()) } - .expectComplete() - .verifyLater() - - instance.readyParty() - - stepVerifier.verify(verificationDuration) - } - @Test fun testUnreadyParty() { val stepVerifier = StepVerifier.create(serverMessagesReceived.take(1)) diff --git a/gradle.properties b/gradle.properties index 8cfa281d..bd57088a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -lombokVersion=1.18.18 +lombokVersion=1.18.24 junitVersion=5.7.1 mockitoVersion=2.24.0 hamcrestVersion=2.2