Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (this *Client) GetConnection() *Connection
- func (this *Client) GetGame() string
- func (this *Client) GetId() int
- func (this *Client) GetName() string
- func (this *Client) GetType() string
- func (this *Client) HandleDisconnect()
- func (this *Client) HandleMessage(raw []byte)
- func (this *Client) IsConnected() bool
- func (this *Client) MarshalJSON() ([]byte, error)
- func (this *Client) SendError(message string)
- func (this *Client) SendMessage(message interface{})
- func (this *Client) SetConnection(connection *Connection)
- func (this *Client) Transfer(client *Client)
- type Connection
- type Game
- func (this *Game) AddPlayer(client *Client)
- func (this *Game) GetHistory() *History
- func (this *Game) GetId() int
- func (this *Game) GetNextPlayerId() int
- func (this *Game) GetPlayerByKey(key string) *Player
- func (this *Game) GetPlayerIds() []int
- func (this *Game) GetStarted() bool
- func (this *Game) GetStopped() bool
- func (this *Game) HandleActionMessage(message *msg.ActionMessage)
- func (this *Game) HandleReconnect(client *Client)
- func (this *Game) HandleStateMessage(message *msg.StateMessage)
- func (this *Game) MarshalJSON() ([]byte, error)
- func (this *Game) RemovePlayer(player *Player)
- func (this *Game) Start() error
- func (this *Game) Stop() error
- type History
- func (this *History) Add(message *msg.StateMessage)
- func (this *History) AddConverted(message *msg.StateMessageOut)
- func (this *History) GetLatest() *msg.StateMessage
- func (this *History) SendAllToViewer(client *Client)
- func (this *History) SendTurnToViewer(client *Client, turn int)
- func (this *History) SendTurnsToViewer(client *Client, from int, to int)
- type JClient
- type JGame
- type JLobby
- type JPlayer
- type JRoom
- type Lobby
- func (this *Lobby) AddGame(game *Game)
- func (this *Lobby) GetGameById(id int) *Game
- func (this *Lobby) HandleConnect(connection *Connection)
- func (this *Lobby) HandleDisconnect(client *Client)
- func (this *Lobby) HandleReconnect(new *Client, old *Client)
- func (this *Lobby) MarshalJSON() ([]byte, error)
- func (this *Lobby) RemoveGame(game *Game)
- func (this *Lobby) SendMessage(clientId int, message interface{})
- func (this *Lobby) TriggerUpdated()
- type Player
- type Room
- func (this *Room) AddClient(client *Client)
- func (this *Room) Broadcast(senderId int, message interface{})
- func (this *Room) BroadcastToType(Type string, message interface{})
- func (this *Room) FindDuplicateUnconnectedClient(client *Client) *Client
- func (this *Room) GetClientById(id int) *Client
- func (this *Room) GetName() string
- func (this *Room) MarshalJSON() ([]byte, error)
- func (this *Room) RemoveClient(client *Client)
Constants ¶
View Source
const ( TYPE_BOT = "bot" TYPE_ENGINE = "engine" TYPE_VIEWER = "viewer" )
View Source
const ( PLAYER_PREFIX = "{[(___" PLAYER_SUFFIX = "___)]}" )
Variables ¶
View Source
var ( CLIENT_TYPES = []string{TYPE_BOT, TYPE_ENGINE, TYPE_VIEWER} CLIENT_COUNTER util.SafeCounter )
View Source
var (
GAME_COUNTER util.SafeCounter
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { sync.RWMutex Id int `json:"id"` Type string `json:"type"` Name string `json:"name"` Game string `json:"game"` // used for bots to specify which game they want to play // contains filtered or unexported fields }
func NewClient ¶
func NewClient(lobby *Lobby, connection *Connection) *Client
func (*Client) GetConnection ¶
func (this *Client) GetConnection() *Connection
func (*Client) HandleDisconnect ¶
func (this *Client) HandleDisconnect()
func (*Client) HandleMessage ¶
func (*Client) IsConnected ¶
func (*Client) MarshalJSON ¶
func (*Client) SendMessage ¶
func (this *Client) SendMessage(message interface{})
func (*Client) SetConnection ¶
func (this *Client) SetConnection(connection *Connection)
type Connection ¶
func NewConnection ¶
func NewConnection(conn *websocket.Conn) *Connection
func (*Connection) HandleDisconnect ¶
func (this *Connection) HandleDisconnect()
func (*Connection) HandleMessage ¶
func (this *Connection) HandleMessage(raw []byte)
func (*Connection) SendMessage ¶
func (this *Connection) SendMessage(message interface{}) error
func (*Connection) SetClient ¶
func (this *Connection) SetClient(client *Client)
func (*Connection) StartPinging ¶
func (this *Connection) StartPinging()
func (*Connection) StopPinging ¶
func (this *Connection) StopPinging()
type Game ¶
type Game struct { Room Id int `json:"id"` Engine *Client `json:"engine"` Players []*Player `json:"players"` History *History `json:"-"` Started bool `json:"started"` Stopped bool `json:"stopped"` }
func (*Game) GetHistory ¶
func (*Game) GetNextPlayerId ¶
func (*Game) GetPlayerByKey ¶
func (*Game) GetPlayerIds ¶
func (*Game) GetStarted ¶
func (*Game) GetStopped ¶
func (*Game) HandleActionMessage ¶
func (this *Game) HandleActionMessage(message *msg.ActionMessage)
func (*Game) HandleReconnect ¶
func (*Game) HandleStateMessage ¶
func (this *Game) HandleStateMessage(message *msg.StateMessage)
func (*Game) MarshalJSON ¶
func (*Game) RemovePlayer ¶
type History ¶
func NewHistory ¶
func NewHistory() *History
func (*History) Add ¶
func (this *History) Add(message *msg.StateMessage)
func (*History) AddConverted ¶
func (this *History) AddConverted(message *msg.StateMessageOut)
func (*History) GetLatest ¶
func (this *History) GetLatest() *msg.StateMessage
func (*History) SendAllToViewer ¶
func (*History) SendTurnToViewer ¶
unused
type Lobby ¶
func (*Lobby) GetGameById ¶
func (*Lobby) HandleConnect ¶
func (this *Lobby) HandleConnect(connection *Connection)
func (*Lobby) HandleDisconnect ¶
func (*Lobby) HandleReconnect ¶
func (*Lobby) MarshalJSON ¶
func (*Lobby) RemoveGame ¶
func (*Lobby) SendMessage ¶
func (*Lobby) TriggerUpdated ¶
func (this *Lobby) TriggerUpdated()
type Player ¶
type Player struct { sync.RWMutex Id int `json:"id"` Client *Client `json:"client"` // contains filtered or unexported fields }
func (*Player) MarshalJSON ¶
type Room ¶
type Room struct { sync.RWMutex Name string `json:"name"` Clients []*Client `json:"clients"` // contains filtered or unexported fields }
func (*Room) BroadcastToType ¶
func (*Room) FindDuplicateUnconnectedClient ¶
func (*Room) GetClientById ¶
func (*Room) MarshalJSON ¶
func (*Room) RemoveClient ¶
Click to show internal directories.
Click to hide internal directories.