server

package
v0.0.0-...-417c3e8 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WssDisconnected = iota
	WssConnecting
	WssConnected
)
View Source
const (
	WsmUpdateRoom      = WsMessage("UPDATE_ROOM")
	WsmUpdateBoard     = WsMessage("UPDATE_BOARD")
	WsmConnectionReady = WsMessage("CONNECTION_READY")
)

Variables

View Source
var Connections = make(map[uuid.UUID]*Client, 100)
View Source
var Rooms = make(map[string]*Room, 100)

Functions

func NewClient

func NewClient() uuid.UUID

Types

type Client

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

func GetClientByUUIDString

func GetClientByUUIDString(u string) (*Client, error)

func (*Client) AddPlayer

func (c *Client) AddPlayer(p *Player) error

func (*Client) ConnectSocket

func (c *Client) ConnectSocket(ws *websocket.Conn) error

func (*Client) DisconnectSocket

func (c *Client) DisconnectSocket() error

func (*Client) GetPlayer

func (c *Client) GetPlayer() (*Player, error)

func (*Client) GetRoom

func (c *Client) GetRoom() (*Room, error)

func (*Client) Login

func (c *Client) Login(p *Player, r *Room) error

func (*Client) SendMessage

func (c *Client) SendMessage(m WsMessage) error

func (*Client) SetPlayer

func (c *Client) SetPlayer(p *Player) error

func (*Client) SetRoom

func (c *Client) SetRoom(r *Room) error

func (*Client) UnsetRoom

func (c *Client) UnsetRoom(r *Room) error

type Player

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

func NewPlayer

func NewPlayer(name string) *Player

func (*Player) GetName

func (p *Player) GetName() string

type Room

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

func GetOrMakeRoom

func GetOrMakeRoom(name string) *Room

func NewRoom

func NewRoom(name string) *Room

func (*Room) AddClient

func (r *Room) AddClient(c *Client)

func (*Room) AddPlayer

func (r *Room) AddPlayer(p *Player) error

func (*Room) MarkCell

func (r *Room) MarkCell(cell int, playerUuid uuid.UUID) error

func (*Room) NotifyClients

func (r *Room) NotifyClients(m WsMessage) error

func (*Room) PlayerExists

func (r *Room) PlayerExists(np *Player) bool

func (*Room) PlayerNames

func (r *Room) PlayerNames() []string

type WsMessage

type WsMessage string

Jump to

Keyboard shortcuts

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