Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BLACK int = 1
BLACK int representing color black in chess
var DEBUG_DECODE = true
DEBUG_DECODE toggles decoding debug messages in the console.
var WHITE int = 0
WHITE int representing the color white in chess
Functions ¶
Types ¶
type Client ¶
Client represents a new websocket connection, with the user's id, and the pool it communicates through.
type GameClient ¶
GameClient represents a new websocket connection to manage games, with the user's id, and the game pool it is connected to.
func (*GameClient) GameRead ¶
func (c *GameClient) GameRead()
GameRead performs the parsing of JSON message, and then appropriately broadcasts the transformed message to other users.
type GameInfo ¶
GameInfo stores the info that should be sent to users seeking to display a list of gamerooms.
type GameMessage ¶
type GameMessage struct { Type int `json:"type"` // 0 = player connected, 1 = board update, 2 = message, 3= opponent leave, 4= spectator join/leave Pid string `json:"pid"` Color int `json:"color"` GameStart bool `json:"start"` GameEnd bool `json:"end"` Message string `json:"message"` Move [2]int `json:"move"` Board [64]int `json:"board"` Entanglements map[string]interface{} `json:"entanglements"` Pieces map[string]interface{} `json:"pieces"` NewBoard [64]int `json:"newBoard"` NewPieces quantumchess.Pieces `json:"newPieces"` NewEntanglements quantumchess.Entanglements `json:"newEntanglements"` }
GameMessage allows us to unpack the content of JSON transmitted through the game pool.
type GamePool ¶
type GamePool struct { ID string Register chan *GameClient Unregister chan *GameClient Clients map[*GameClient]int // maps to BLACK or WHITE, both cannot be the same obviously Broadcast chan GameMessage //Timer channel //Timeout channel //Players [2]string Start bool Over bool }
GamePool manages the communication channels of a specific Game room.
func NewGamePool ¶
NewGamePool builds a new game room with the given id.
type Message ¶
type Message struct { Type int `json:type` Players string `json:"players"` ID string `json:"id"` QueueId string `json:"queue"` }
Message target object to decode the JSON messages of the general websocket connection.