diff --git a/deploy.sh b/deploy.sh index b5e5bc7..6d6222c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -2,7 +2,7 @@ set -e echo "Pulling latest..." -git pull +#git pull echo "Building..." go build -o overte-api . diff --git a/hub.go b/hub.go index f57e980..a5fcc92 100644 --- a/hub.go +++ b/hub.go @@ -64,22 +64,22 @@ func (h *Hub) count() int { // SendToUser sends a message to the first client identified as username. func (h *Hub) SendToUser(username string, msg interface{}) { - data, err := json.Marshal(msg) - if err != nil { - return - } - h.mu.RLock() - defer h.mu.RUnlock() - for c := range h.clients { - if c.username == username { - select { - case c.send <- data: - default: - log.Printf("[WS] dropped private message to %s", username) - } - return - } - } + data, err := json.Marshal(msg) + if err != nil { + return + } + h.mu.RLock() + defer h.mu.RUnlock() + for c := range h.clients { + if c.username == username { + select { + case c.send <- data: + default: + log.Printf("[WS] dropped private message to %s (channel full)", username) + } + // no return — send to all matching clients + } + } } func (h *Hub) Broadcast(msg interface{}, sender *Client) { diff --git a/poker/table.go b/poker/table.go index 89311a2..7c701e6 100644 --- a/poker/table.go +++ b/poker/table.go @@ -415,25 +415,21 @@ func (t *Table) Reveal(username string) { func (t *Table) advance() { t.mu.Lock() - defer t.mu.Unlock() - // Check if only one player remains if t.countActivePlayers() == 1 { + t.mu.Unlock() t.awardPot() return } - // Check if betting is complete for this street if !t.bettingComplete() { t.Hand.ActionOn = t.nextActiveSeat(t.Hand.ActionOn) t.mu.Unlock() t.broadcastState() t.startTurnTimer() - t.mu.Lock() return } - // Advance to next street switch t.Hand.Phase { case PhasePreflop: var cards []string @@ -454,24 +450,19 @@ func (t *Table) advance() { t.Hand.Phase = PhaseShowdown t.mu.Unlock() t.doShowdown() - t.mu.Lock() return } - // Reset bets for new street for _, s := range t.Seats { s.Bet = 0 } t.acted = make(map[string]bool) t.Hand.LastRaise = 0 t.Hand.MinRaise = t.Config.BigBlind - - // Action starts left of dealer post-flop t.Hand.ActionOn = t.nextActiveSeat(t.Hand.DealerSeat) t.mu.Unlock() t.broadcastState() t.startTurnTimer() - t.mu.Lock() } func (t *Table) doShowdown() {