Skip to content

Commit b47df51

Browse files
authored
Send initial update when entering matchmaking lobby (#457)
1 parent da6b675 commit b47df51

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

osu.Server.Spectator/Hubs/Multiplayer/Matchmaking/Queue/MatchmakingQueueBackgroundService.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public bool IsInQueue(MultiplayerClientState state)
8484
public async Task AddToLobbyAsync(MultiplayerClientState state)
8585
{
8686
await hub.Groups.AddToGroupAsync(state.ConnectionId, lobby_users_group);
87+
await sendLobbyUpdate(hub.Clients.Client(state.ConnectionId));
8788
}
8889

8990
public async Task RemoveFromLobbyAsync(MultiplayerClientState state)
@@ -210,16 +211,23 @@ private async Task updateLobby()
210211
if (DateTimeOffset.Now - lastLobbyUpdateTime < lobby_update_rate)
211212
return;
212213

214+
await sendLobbyUpdate(hub.Clients.Group(lobby_users_group));
215+
216+
lastLobbyUpdateTime = DateTimeOffset.Now;
217+
}
218+
219+
private async Task sendLobbyUpdate(IClientProxy clients)
220+
{
213221
MatchmakingQueueUser[] users = poolQueues.Values.SelectMany(queue => queue.GetAllUsers()).ToArray();
214222
Random.Shared.Shuffle(users);
215223
int[] usersSample = users.Take(50).Select(u => u.UserId).ToArray();
216224

217-
await hub.Clients.Group(lobby_users_group).SendAsync(nameof(IMatchmakingClient.MatchmakingLobbyStatusChanged), new MatchmakingLobbyStatus
225+
var status = new MatchmakingLobbyStatus
218226
{
219227
UsersInQueue = usersSample
220-
});
228+
};
221229

222-
lastLobbyUpdateTime = DateTimeOffset.Now;
230+
await clients.SendAsync(nameof(IMatchmakingClient.MatchmakingLobbyStatusChanged), status);
223231
}
224232

225233
private async Task refreshQueues()

0 commit comments

Comments
 (0)