Do not include WebSocket client support by default

This commit is contained in:
Trevor Slocum 2024-07-22 02:15:56 -07:00
parent bde555532e
commit dd38c10f32
3 changed files with 26 additions and 25 deletions

View file

@ -1,3 +1,5 @@
//go:build full
package server
import (

View file

@ -12,7 +12,6 @@ import (
"log"
"math/big"
"net"
"net/http"
"os"
"os/exec"
"regexp"
@ -242,30 +241,6 @@ func (s *server) handleListener(listener net.Listener) {
}
}
func (s *server) handleWebSocket(w http.ResponseWriter, r *http.Request) {
const bufferSize = 8
commands := make(chan []byte, bufferSize)
events := make(chan []byte, bufferSize)
wsClient := newWebSocketClient(r, w, commands, events, s.verbose)
if wsClient == nil {
return
}
now := time.Now().Unix()
c := &serverClient{
id: <-s.newClientIDs,
language: "bgammon-en",
accountID: -1,
connected: now,
active: now,
commands: commands,
Client: wsClient,
}
s.handleClient(c)
}
func (s *server) nameAllowed(username []byte) bool {
return !guestName.Match(username)
}

View file

@ -44,6 +44,30 @@ func (s *server) listenWebSocket(address string) {
log.Fatalf("failed to listen on %s: %s", address, err)
}
func (s *server) handleWebSocket(w http.ResponseWriter, r *http.Request) {
const bufferSize = 8
commands := make(chan []byte, bufferSize)
events := make(chan []byte, bufferSize)
wsClient := newWebSocketClient(r, w, commands, events, s.verbose)
if wsClient == nil {
return
}
now := time.Now().Unix()
c := &serverClient{
id: <-s.newClientIDs,
language: "bgammon-en",
accountID: -1,
connected: now,
active: now,
commands: commands,
Client: wsClient,
}
s.handleClient(c)
}
func (s *server) cachedMatches() []byte {
s.gamesCacheLock.Lock()
defer s.gamesCacheLock.Unlock()