This commit is contained in:
parent
d6630ece24
commit
b43c6210be
2 changed files with 56 additions and 0 deletions
|
|
@ -720,6 +720,24 @@ func (m *ChessMatch) MatchSignal(ctx context.Context, logger runtime.Logger, db
|
|||
if data == "cancel" {
|
||||
logger.Info("Match cancelled via signal")
|
||||
s.PendingCancel = true
|
||||
|
||||
// Broadcast cancellation to any connected clients
|
||||
msg, _ := json.Marshal(map[string]interface{}{
|
||||
"result": "cancelled",
|
||||
"reason": "Challenge cancelled by creator",
|
||||
})
|
||||
dispatcher.BroadcastMessage(OpCodeGameOver, msg, nil, nil, true)
|
||||
|
||||
// Update match label to cancelled status so it's not detected as active
|
||||
label := MatchLabel{
|
||||
Game: "chess960",
|
||||
Status: "cancelled",
|
||||
White: s.WhiteName,
|
||||
WhiteID: s.WhiteID,
|
||||
PositionID: s.PositionID,
|
||||
}
|
||||
labelJSON, _ := json.Marshal(label)
|
||||
dispatcher.MatchLabelUpdate(string(labelJSON))
|
||||
}
|
||||
|
||||
return s, ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue