mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
feat: publish matchmaking state events
This commit is contained in:
+11
-2
@@ -197,6 +197,7 @@ func (s *Service) queueCreate(w http.ResponseWriter, r *http.Request) {
|
||||
writeDomainError(w, err)
|
||||
return
|
||||
}
|
||||
s.publishTicketEvent(ticket, now)
|
||||
writeJSON(w, http.StatusCreated, toQueueResponse(ticket))
|
||||
return
|
||||
}
|
||||
@@ -225,6 +226,7 @@ func (s *Service) queueCreate(w http.ResponseWriter, r *http.Request) {
|
||||
writeDomainError(w, err)
|
||||
return
|
||||
}
|
||||
s.publishTicketEvent(ticket, now)
|
||||
writeJSON(w, http.StatusCreated, toQueueResponse(ticket))
|
||||
}
|
||||
|
||||
@@ -366,6 +368,7 @@ func (s *Service) queueMutation(w http.ResponseWriter, r *http.Request) {
|
||||
writeDomainError(w, err)
|
||||
return
|
||||
}
|
||||
s.publishTicketEvent(ticket, now)
|
||||
if r.Header.Get("X-Contract-Delete") == "1" {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return
|
||||
@@ -404,7 +407,10 @@ func (s *Service) proposalMutation(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusNotFound, "not_found")
|
||||
return
|
||||
}
|
||||
proposal.Expire(s.now())
|
||||
now := s.now()
|
||||
if proposal.Expire(now) {
|
||||
s.publishProposalEvent(*proposal, now)
|
||||
}
|
||||
writeJSON(w, http.StatusOK, toProposalResponse(*proposal))
|
||||
return
|
||||
}
|
||||
@@ -429,11 +435,13 @@ func (s *Service) proposalMutation(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusNotFound, "not_found")
|
||||
return
|
||||
}
|
||||
updated, err := proposal.Respond(playerID, key, parts[1] == "accept", revision, s.now())
|
||||
now := s.now()
|
||||
updated, err := proposal.Respond(playerID, key, parts[1] == "accept", revision, now)
|
||||
if err != nil {
|
||||
writeDomainError(w, err)
|
||||
return
|
||||
}
|
||||
s.publishProposalEvent(updated, now)
|
||||
writeJSON(w, http.StatusOK, toProposalResponse(updated))
|
||||
}
|
||||
|
||||
@@ -465,6 +473,7 @@ func (s *Service) assignment(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusServiceUnavailable, "assignment_unavailable")
|
||||
return
|
||||
}
|
||||
_ = s.PublishControlPlaneEvent(ControlPlaneEvent{Event: "assignment_changed", Revision: 0, ResourceID: view.MatchID, OccurredAt: now, MatchID: view.MatchID, ServerID: view.ServerID, PlayerID: view.PlayerID})
|
||||
writeJSON(w, http.StatusOK, view)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user