fix(multiplayer): recover assignment handoff

This commit is contained in:
Josh Creek
2026-09-02 18:47:00 +01:00
parent 84d27d82da
commit 91658fbc13
12 changed files with 147 additions and 15 deletions
+2 -1
View File
@@ -349,6 +349,7 @@ type queueCreateRequest struct {
type queueResponse struct {
TicketID string `json:"ticket_id"`
PlayerID string `json:"player_id"`
MatchID string `json:"match_id,omitempty"`
State string `json:"state"`
Revision uint64 `json:"revision"`
EnqueuedAt time.Time `json:"enqueued_at"`
@@ -1116,7 +1117,7 @@ func decodeBody(w http.ResponseWriter, r *http.Request, target any) bool {
}
func toQueueResponse(ticket domain.QueueTicket) queueResponse {
return queueResponse{TicketID: ticket.TicketID, PlayerID: ticket.PlayerID, Playlist: string(ticket.Playlist), State: string(ticket.State), Revision: ticket.Revision, EnqueuedAt: ticket.EnqueuedAt, ExpiresAt: ticket.ExpiresAt}
return queueResponse{TicketID: ticket.TicketID, PlayerID: ticket.PlayerID, MatchID: ticket.MatchID, Playlist: string(ticket.Playlist), State: string(ticket.State), Revision: ticket.Revision, EnqueuedAt: ticket.EnqueuedAt, ExpiresAt: ticket.ExpiresAt}
}
func toProposalResponse(proposal domain.Proposal) proposalResponse {
+7
View File
@@ -22,6 +22,13 @@ import (
type queueBackendSpy struct{ createCalls, heartbeatCalls, cancelCalls, getCalls int }
func TestQueueResponseCarriesRecoveredMatchIdentity(t *testing.T) {
response := toQueueResponse(domain.QueueTicket{TicketID: "ticket-1234567890", PlayerID: "player-1234567890", MatchID: "match-1234567890", State: domain.AssignmentReady})
if response.MatchID != "match-1234567890" {
t.Fatalf("queue response match ID = %q", response.MatchID)
}
}
type candidateIndexSpy struct {
upsertCalls, removeCalls int
upsertErr, removeErr error