Switch from github.com/nhooyr/websocket to github.com/coder/websocket

This commit is contained in:
Trevor Slocum 2024-08-18 10:44:13 -07:00
parent e769215e74
commit cf737ec690
3 changed files with 9 additions and 18 deletions

View file

@ -4,11 +4,10 @@ import (
"bufio"
"bytes"
"context"
"crypto/rand"
"fmt"
"log"
"math"
"math/big"
"math/rand"
"net"
"os"
"regexp"
@ -17,7 +16,7 @@ import (
"code.rocket9labs.com/tslocum/bei"
"code.rocket9labs.com/tslocum/bgammon"
"nhooyr.io/websocket"
"github.com/coder/websocket"
)
var Debug int
@ -560,7 +559,7 @@ func (c *Client) handleEvents() {
case *bgammon.EventWin:
log.Printf("%s wins!", ev.Player)
if ev.Player != c.game.Player1.Name {
c.Out <- []byte(fmt.Sprintf("say %s", phrases[randInt(len(phrases))]))
c.Out <- []byte(fmt.Sprintf("say %s", phrases[rand.Intn(len(phrases))]))
}
c.Out <- []byte("say Good game. Play again?")
c.Out <- []byte("rematch")
@ -575,14 +574,6 @@ func (c *Client) handleEvents() {
}
}
func randInt(max int) int {
i, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
panic(err)
}
return int(i.Int64())
}
var phrases = [][]byte{
[]byte("Gadzooks! I accidentally lost by mistake."),
[]byte("My checkers began too close to your home board."),

4
go.mod
View file

@ -4,8 +4,8 @@ go 1.17
require (
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240720003230-1e079dcccf22
nhooyr.io/websocket v1.8.11
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240818173949-9bcc4061a97a
github.com/coder/websocket v1.8.12
)
require code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999 // indirect

8
go.sum
View file

@ -1,8 +1,8 @@
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c=
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240720003230-1e079dcccf22 h1:D1nKA9WbDvPXNt00b4TwoTqeCiG1jK2/P41uwjoAmVA=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240720003230-1e079dcccf22/go.mod h1:z9MOUNGBYmJC0XY8Mac40nYbTwzvosmKjpF04Vr8CWo=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240818173949-9bcc4061a97a h1:7uPqjCwEpLbMMnkLao2W/vEHj00ACHdwxjXpMJu/K/Q=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240818173949-9bcc4061a97a/go.mod h1:dOw6hXK/M4KZDq29FZX6Smd4sQJ21tEun/6+0Y3RFVA=
code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999 h1:PwfoDBtxVT3TwL2KpoijPKi6NQsGu6cXhPVoQeqKJWM=
code.rocket9labs.com/tslocum/tabula v0.0.0-20240703054156-ce0b448f0999/go.mod h1:WEJXESKXqrMFLAArikQ79lpRibNeeE1C0VruxXYMF5M=
nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=