fix(matchmaking): broadcast player list so queue avatars appear for all waiting players
BroadcastQueueLocked now sends the full waiting-player list (name/avatar/level) alongside the count. The client maps it onto mm.players so every queued player's avatar shows in the 4-slot grid for all waiting users, not just the slot-0 viewer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,8 @@ public record GameStateDto(
|
|||||||
bool Ranked,
|
bool Ranked,
|
||||||
int Stake);
|
int Stake);
|
||||||
|
|
||||||
public record MatchmakingStateDto(string Phase, int Players, int? QueuePosition);
|
public record QueuePlayerDto(string Id, string Name, string Avatar, string? AvatarImage, int Level);
|
||||||
|
public record MatchmakingStateDto(string Phase, int Players, int? QueuePosition, QueuePlayerDto[]? Queue = null);
|
||||||
public record ReactionDto(int Seat, string Reaction);
|
public record ReactionDto(int Seat, string Reaction);
|
||||||
|
|
||||||
public static class Map
|
public static class Map
|
||||||
|
|||||||
@@ -88,13 +88,16 @@ public sealed partial class GameManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Push the current queue size to every waiting player (call inside _mmLock).</summary>
|
/// <summary>Push the current queue size + player list to every waiting player (call inside _mmLock).</summary>
|
||||||
private void BroadcastQueueLocked()
|
private void BroadcastQueueLocked()
|
||||||
{
|
{
|
||||||
int n = _waiting.Count;
|
var queue = _waiting
|
||||||
|
.Select(w => new QueuePlayerDto(w.player.UserId, w.player.Name, w.player.Avatar, w.player.AvatarImage, w.player.Level))
|
||||||
|
.ToArray();
|
||||||
|
int n = queue.Length;
|
||||||
foreach (var w in _waiting)
|
foreach (var w in _waiting)
|
||||||
_ = _hub.Clients.User(w.player.UserId).SendAsync("matchmaking",
|
_ = _hub.Clients.User(w.player.UserId).SendAsync("matchmaking",
|
||||||
new MatchmakingStateDto("searching", n, null));
|
new MatchmakingStateDto("searching", n, null, queue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Client safety net: re-send the current game state to a player who
|
/// <summary>Client safety net: re-send the current game state to a player who
|
||||||
|
|||||||
@@ -159,8 +159,9 @@ export class SignalrService implements OnlineService {
|
|||||||
.configureLogging(signalR.LogLevel.Warning)
|
.configureLogging(signalR.LogLevel.Warning)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
conn.on("matchmaking", (s: { phase: string; players: number; queuePosition: number | null }) =>
|
conn.on("matchmaking", (s: { phase: string; players: number; queuePosition: number | null; queue?: Array<{ id: string; name: string; avatar: string; avatarImage?: string; level: number }> }) =>
|
||||||
this.emitMM(s.phase, s.queuePosition ?? undefined, s.players));
|
this.emitMM(s.phase, s.queuePosition ?? undefined, s.players,
|
||||||
|
s.queue?.map(p => ({ id: p.id, displayName: p.name, avatar: p.avatar, avatarImage: p.avatarImage, level: p.level, rating: 0 }))));
|
||||||
conn.on("matchFound", () => {
|
conn.on("matchFound", () => {
|
||||||
this.emitMM("ready");
|
this.emitMM("ready");
|
||||||
// Safety net: if the initial state never lands (dropped/raced), ask the
|
// Safety net: if the initial state never lands (dropped/raced), ask the
|
||||||
@@ -226,10 +227,15 @@ export class SignalrService implements OnlineService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private emitMM(phase: string, queuePosition?: number, waiting?: number) {
|
private emitMM(
|
||||||
|
phase: string,
|
||||||
|
queuePosition?: number,
|
||||||
|
waiting?: number,
|
||||||
|
queuePlayers?: Array<{ id: string; displayName: string; avatar: string; avatarImage?: string; level: number; rating: number }>
|
||||||
|
) {
|
||||||
const state: MatchmakingState = {
|
const state: MatchmakingState = {
|
||||||
phase: phase as MatchmakingState["phase"],
|
phase: phase as MatchmakingState["phase"],
|
||||||
players: [],
|
players: queuePlayers ?? [],
|
||||||
elapsedMs: 0,
|
elapsedMs: 0,
|
||||||
ranked: this.mmRanked,
|
ranked: this.mmRanked,
|
||||||
stake: this.mmStake,
|
stake: this.mmStake,
|
||||||
|
|||||||
Reference in New Issue
Block a user