server

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientMessage

type ClientMessage struct {
	Type    string  `json:"type"`
	Marbles [][]int `json:"marbles,omitempty"` // [[q,r], ...]
	Dir     []int   `json:"direction,omitempty"`
}

ClientMessage represents a message from the client

type Player

type Player struct {
	Conn  *websocket.Conn
	Color game.Cell
}

Player represents a connected player

type PlayerColor

type PlayerColor int

PlayerColor maps to game.Cell

const (
	ColorBlack PlayerColor = PlayerColor(game.Black)
	ColorWhite PlayerColor = PlayerColor(game.White)
)

type Room

type Room struct {
	Code    string
	Game    *game.Game
	Players [2]*Player // [0] = host (Black), [1] = joiner (White)
	// contains filtered or unexported fields
}

Room represents an active game room

type RoomManager

type RoomManager struct {
	// contains filtered or unexported fields
}

RoomManager manages all active game rooms

func NewRoomManager

func NewRoomManager() *RoomManager

NewRoomManager creates a new room manager

func (*RoomManager) CreateRoom

func (rm *RoomManager) CreateRoom() *Room

CreateRoom creates a new game room with a unique code

func (*RoomManager) GetRoom

func (rm *RoomManager) GetRoom(code string) *Room

GetRoom returns the room with the given code, or nil if not found

func (*RoomManager) RemoveRoom

func (rm *RoomManager) RemoveRoom(code string)

RemoveRoom removes a room from the manager

func (*RoomManager) RemoveRoomIfEmpty

func (rm *RoomManager) RemoveRoomIfEmpty(code string)

RemoveRoomIfEmpty removes a room only if both player slots are nil.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the Abalone HTTP and WebSocket server

func NewServer

func NewServer(webFS http.FileSystem) *Server

NewServer creates a new server with the given filesystem for static assets

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe starts the HTTP server on the given address

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface

type ServerMessage

type ServerMessage struct {
	Type     string         `json:"type"`
	Board    map[string]int `json:"board,omitempty"`
	Turn     string         `json:"turn,omitempty"`
	Captured map[string]int `json:"captured,omitempty"`
	Winner   string         `json:"winner,omitempty"`
	Code     string         `json:"code,omitempty"`
	Color    string         `json:"color,omitempty"`
	Message  string         `json:"message,omitempty"`
	Error    string         `json:"error,omitempty"`
}

ServerMessage represents a message from the server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL