Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send match_ready to server immediatley on match_found (#1783) #2324

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,14 @@ public interface FafServerAccessor {

void gameMatchmaking(MatchmakingQueue queue, MatchmakingState state);

void gameMatchmakingReady(boolean ready);

void inviteToParty(Player recipient);

void acceptPartyInvite(Player sender);

void kickPlayerFromParty(Player kickedPlayer);

void readyParty();

void unreadyParty();

void leaveParty();

void setPartyFactions(List<Faction> factions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@
import com.faforever.client.remote.domain.outbound.faf.ListPersonalAvatarsMessage;
import com.faforever.client.remote.domain.outbound.faf.LoginOauthClientMessage;
import com.faforever.client.remote.domain.outbound.faf.MakeBroadcastMessage;
import com.faforever.client.remote.domain.outbound.faf.MatchReadyMessage;
import com.faforever.client.remote.domain.outbound.faf.MatchmakerInfoOutboundMessage;
import com.faforever.client.remote.domain.outbound.faf.PingMessage;
import com.faforever.client.remote.domain.outbound.faf.PongMessage;
import com.faforever.client.remote.domain.outbound.faf.ReadyPartyMessage;
import com.faforever.client.remote.domain.outbound.faf.RemoveFoeMessage;
import com.faforever.client.remote.domain.outbound.faf.RemoveFriendMessage;
import com.faforever.client.remote.domain.outbound.faf.RestoreGameSessionMessage;
import com.faforever.client.remote.domain.outbound.faf.SelectAvatarMessage;
import com.faforever.client.remote.domain.outbound.faf.SetPartyFactionsMessage;
import com.faforever.client.remote.domain.outbound.faf.UnreadyPartyMessage;
import com.faforever.client.remote.domain.outbound.gpg.GpgOutboundMessage;
import com.faforever.client.reporting.ReportingService;
import com.faforever.client.serialization.FactionMixin;
Expand Down Expand Up @@ -558,6 +557,11 @@ public void gameMatchmaking(MatchmakingQueue queue, MatchmakingState state) {
writeToServer(new GameMatchmakingMessage(queue.getTechnicalName(), state));
}

@Override
public void gameMatchmakingReady(boolean ready) {
writeToServer(new MatchReadyMessage(ready));
}

@Override
public void inviteToParty(Player recipient) {
writeToServer(new InviteToPartyMessage(recipient.getId()));
Expand All @@ -573,16 +577,6 @@ public void kickPlayerFromParty(Player kickedPlayer) {
writeToServer(new KickPlayerFromPartyMessage(kickedPlayer.getId()));
}

@Override
public void readyParty() {
writeToServer(new ReadyPartyMessage());
}

@Override
public void unreadyParty() {
writeToServer(new UnreadyPartyMessage());
}

@Override
public void leaveParty() {
writeToServer(new LeavePartyMessage());
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/com/faforever/client/remote/FafService.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,6 @@ public void leaveParty() {
fafServerAccessor.leaveParty();
}

public void readyParty() {
fafServerAccessor.readyParty();
}

public void unreadyParty() {
fafServerAccessor.unreadyParty();
}

public void setPartyFactions(List<Faction> factions) {
fafServerAccessor.setPartyFactions(factions);
}
Expand All @@ -599,6 +591,10 @@ public void updateMatchmakerState(MatchmakingQueue queue, MatchmakingState state
fafServerAccessor.gameMatchmaking(queue, state);
}

public void readyForMatchLaunch(boolean ready) {
fafServerAccessor.gameMatchmakingReady(ready);
}

@Async
public CompletableFuture<Optional<Clan>> getClanByTag(String tag) {
return CompletableFuture.completedFuture(fafApiAccessor.getClanByTag(tag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,27 +302,22 @@ public void gameMatchmaking(MatchmakingQueue queue, MatchmakingState state) {
}

@Override
public void inviteToParty(com.faforever.client.player.Player recipient) {

}

@Override
public void acceptPartyInvite(com.faforever.client.player.Player sender) {
public void gameMatchmakingReady(boolean ready) {

}

@Override
public void kickPlayerFromParty(com.faforever.client.player.Player kickedPlayer) {
public void inviteToParty(com.faforever.client.player.Player recipient) {

}

@Override
public void readyParty() {
public void acceptPartyInvite(com.faforever.client.player.Player sender) {

}

@Override
public void unreadyParty() {
public void kickPlayerFromParty(com.faforever.client.player.Player kickedPlayer) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.faforever.client.remote.domain.inbound.faf.LoginMessage;
import com.faforever.client.remote.domain.inbound.faf.MatchCancelledMessage;
import com.faforever.client.remote.domain.inbound.faf.MatchFoundMessage;
import com.faforever.client.remote.domain.inbound.faf.MatchInfoMessage;
import com.faforever.client.remote.domain.inbound.faf.MatchmakerInfoMessage;
import com.faforever.client.remote.domain.inbound.faf.NoticeMessage;
import com.faforever.client.remote.domain.inbound.faf.PartyInviteMessage;
Expand Down Expand Up @@ -50,6 +51,7 @@
@Type(value = MatchmakerInfoMessage.class, name = MatchmakerInfoMessage.COMMAND),
@Type(value = MatchFoundMessage.class, name = MatchFoundMessage.COMMAND),
@Type(value = MatchCancelledMessage.class, name = MatchCancelledMessage.COMMAND),
@Type(value = MatchInfoMessage.class, name = MatchInfoMessage.COMMAND),
@Type(value = SocialMessage.class, name = SocialMessage.COMMAND),
@Type(value = AuthenticationFailedMessage.class, name = AuthenticationFailedMessage.COMMAND),
@Type(value = UpdatedAchievementsMessage.class, name = UpdatedAchievementsMessage.COMMAND),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.faforever.client.remote.domain.inbound.faf;

import java.time.LocalDateTime;

import lombok.EqualsAndHashCode;
import lombok.Value;

@EqualsAndHashCode(callSuper = true)
@Value
public class MatchInfoMessage extends FafInboundMessage {
public static final String COMMAND = "match_info";
String expiresAt;// TODO if this was a proper ISO date it could probably be auto-parsed to LocalDateTime by jackson
int playersTotal;
int playersReady;
boolean ready;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
import com.faforever.client.remote.domain.outbound.faf.ListPersonalAvatarsMessage;
import com.faforever.client.remote.domain.outbound.faf.LoginOauthClientMessage;
import com.faforever.client.remote.domain.outbound.faf.MakeBroadcastMessage;
import com.faforever.client.remote.domain.outbound.faf.MatchReadyMessage;
import com.faforever.client.remote.domain.outbound.faf.MatchmakerInfoOutboundMessage;
import com.faforever.client.remote.domain.outbound.faf.PingMessage;
import com.faforever.client.remote.domain.outbound.faf.PongMessage;
import com.faforever.client.remote.domain.outbound.faf.ReadyPartyMessage;
import com.faforever.client.remote.domain.outbound.faf.RemoveFoeMessage;
import com.faforever.client.remote.domain.outbound.faf.RemoveFriendMessage;
import com.faforever.client.remote.domain.outbound.faf.RemoveSocialMessage;
import com.faforever.client.remote.domain.outbound.faf.RestoreGameSessionMessage;
import com.faforever.client.remote.domain.outbound.faf.SelectAvatarMessage;
import com.faforever.client.remote.domain.outbound.faf.SetPartyFactionsMessage;
import com.faforever.client.remote.domain.outbound.faf.UnreadyPartyMessage;
import com.faforever.client.remote.domain.outbound.gpg.AIOptionMessage;
import com.faforever.client.remote.domain.outbound.gpg.ChatMessage;
import com.faforever.client.remote.domain.outbound.gpg.ClearSlotMessage;
Expand Down Expand Up @@ -90,11 +89,10 @@
@Type(value = AcceptPartyInviteMessage.class, name = AcceptPartyInviteMessage.COMMAND),
@Type(value = KickPlayerFromPartyMessage.class, name = KickPlayerFromPartyMessage.COMMAND),
@Type(value = LeavePartyMessage.class, name = LeavePartyMessage.COMMAND),
@Type(value = ReadyPartyMessage.class, name = ReadyPartyMessage.COMMAND),
@Type(value = UnreadyPartyMessage.class, name = UnreadyPartyMessage.COMMAND),
@Type(value = SetPartyFactionsMessage.class, name = SetPartyFactionsMessage.COMMAND),
@Type(value = GameMatchmakingMessage.class, name = GameMatchmakingMessage.COMMAND),
@Type(value = MatchmakerInfoOutboundMessage.class, name = MatchmakerInfoOutboundMessage.COMMAND),
@Type(value = MatchReadyMessage.class, name = MatchReadyMessage.COMMAND),
@Type(value = LoginOauthClientMessage.class, name = LoginOauthClientMessage.COMMAND),
// GPG Client Messages not directly instantiated they are only forwarded from the game
// Listing here serves as documentation of known messages
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.faforever.client.remote.domain.outbound.faf;

import lombok.EqualsAndHashCode;
import lombok.Value;

/**
* When matchmaker finds a match, all players needs to ready up for game to get
* launched.
*/
@EqualsAndHashCode(callSuper = true)
@Value
public class MatchReadyMessage extends FafOutboundMessage {
public static final String COMMAND = "match_ready";

boolean ready;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ protected void onMatchFoundMessage(MatchFoundMessage message) {
i18n.get("teammatchmaking.notification.matchFound.title"),
i18n.get("teammatchmaking.notification.matchFound.message")
));
fafService.readyForMatchLaunch(true); // remove when implementing full match ready UI

matchmakingQueues.stream()
.filter(matchmakingQueue -> Objects.equals(matchmakingQueue.getTechnicalName(), message.getQueueName()))
.forEach(matchmakingQueue -> matchmakingQueue.setTimedOutMatchingStatus(MatchingStatus.MATCH_FOUND, Duration.ofSeconds(60), taskScheduler));
Expand Down Expand Up @@ -346,14 +348,6 @@ private void initializeParty() {
}
}

public void readyParty() {
fafService.readyParty();
}

public void unreadyParty() {
fafService.unreadyParty();
}

public void sendFactionSelection(List<Faction> factions) {
fafService.setPartyFactions(factions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,19 +571,12 @@ public void testKickPlayerFromParty() {
"kick_player_from_party",
String.valueOf(player.getId()));
}

@Test
public void testReadyParty() {
instance.readyParty();

assertMessageContainsComponents("ready_party");
}


@Test
public void testUnreadyParty() {
instance.unreadyParty();
public void testPlayerReadyForMatch() {
instance.gameMatchmakingReady(true);

assertMessageContainsComponents("unready_party");
assertMessageContainsComponents("match_ready");
}

@Test
Expand Down