mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 12:02:02 +00:00
fix(multiplayer): recover assignment handoff
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user