Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DefaultClient = NewClient()
)
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct { Call string `json:"call"` ID ID `json:"id"` Param json.RawMessage `json:"param,omitempty"` }
func NewFlipCall ¶
func NewSetupCall ¶
func NewSubscribeCall ¶
func NewSubscribeCall(id, feed ID, serial EBoardSerial) Call
type Client ¶
type Client interface {
EBoards(ctx context.Context) ([]EBoardResponse, error)
}
Client is a LiveChess client.
type ClockResponse ¶
type ClockResponse struct { // White represents white: number of seconds for white on the clock. White int `json:"white,omitempty"` // Black represents black: number of seconds for black on the clock. Black int `json:"black,omitempty"` // Run represents run: null if the clock is not running, otherwise true for running clock for white, false when clock is running for black. Run *bool `json:"run,omitempty"` // Time represents time: timestamp in milliseconds when this information was retrieved from the clock. This allows for the calculation of the running clock value. Time int `json:"time,omitempty"` }
type EBoardEventResponse ¶
type EBoardEventResponse struct { // serialnr: string with the serialnr of the board generating an event SerialNr EBoardSerial `json:"serialnr"` // flipped: indicator if the board is flipped or not Flipped bool `json:"flipped"` // board: current position on the board, may be omitted if there was no board change Board string `json:"board,omitempty"` // clock: value of the clock, may be omitted if there was no clock change Clock *ClockResponse `json:"clock,omitempty"` // start: FEN string with the position from where reconstruction of moves is done Start string `json:"start,omitempty"` // san: array of SAN values with the detected moves San []string `json:"san"` // match: boolean indicating if the current board exactly matches the reconstructed move Match bool `json:"match"` }
type EBoardResponse ¶
type EBoardResponse struct { // SerialNr is the serial number of the board. This is a unique key. SerialNr EBoardSerial `json:"serialnr"` // Source is the name of the source for this eboard. This corresponds to the device field in sources. // This value will be null if the board is not present. Source string `json:"source,omitempty"` // Status information State EBoardState `json:"state,omitempty"` // Battery is string with battery information if a battery is present. This will be a floating // point number followed by % (bluetooth boards) or V (when connected to a caissa module). Battery string `json:"battery,omitempty"` // Comments is a string or null with an operator comment on the board. Comment string `json:"comment,omitempty"` // Board is a string containing the board part of a FEN string with the pieces detected on the board. Board string `json:"board,omitempty"` // Flipped is true if the board is flipped Flipped bool `json:"flipped"` // Clock include clock information, when a clock is present. Clock *ClockResponse `json:"clock,omitempty"` }
type EBoardSerial ¶
type EBoardSerial string
EBoardSerial represents the eboard serial number.
func AutoDetect ¶
func AutoDetect(ctx context.Context, client Client) (EBoardSerial, error)
AutoDetect returns the serial number of the likely eboard to use. It is likely if it's the only one altogether or the only one ACTIVE of multiple.
type EBoardState ¶
type EBoardState string
EBoardState represents the eboard state.
const ( // NotActivated represents null: board has not yet been activated, typically source will be null to NotActivated EBoardState = "" // Active represents ‘ACTIVE’: board is alive and well Active EBoardState = "ACTIVE" // Inactive represents ‘INACTIVE’: board is not active because of operator action Inactive EBoardState = "INACTIVE" // NotResponding represents ‘NOTRESPONDING’: board is not responding to requests NotResponding EBoardState = "NOTRESPONDING" // Delayed represents ‘DELAYED’: board is present but board information is behind the real board state. // This kind of state only occurs in wireless setups of Caissa Delayed EBoardState = "DELAYED" )
type ErrorParam ¶
type ErrorParam struct {
Message string `json:"message,omitempty"`
}
type FeedClient ¶
type FeedClient interface { Setup(ctx context.Context, fen string) error Flip(ctx context.Context, flipped bool) error }
func NewFeed ¶
func NewFeed(ctx context.Context, serial EBoardSerial) (FeedClient, <-chan EBoardEventResponse, error)
type FeedParam ¶
type FeedParam struct { Feed string `json:"feed,omitempty"` // "eboardevent" ID ID `json:"id,omitempty"` Param json.RawMessage `json:"param,omitempty"` }
type MethodParam ¶
type MethodParam struct { Method string `json:"method,omitempty"` // "setup", "unsubscribe ID ID `json:"id,omitempty"` Param json.RawMessage `json:"param,omitempty"` }
type Response ¶
type Response struct { Response ResponseType `json:"response"` // "call", "error", "feed" ID ID `json:"id"` // id of call or feed Param json.RawMessage `json:"param,omitempty"` Time int `json:"time"` }
type ResponseType ¶
type ResponseType string
const ( CallResponse ResponseType = "call" FeedResponse ResponseType = "feed" ErrorResponse ResponseType = "error" )
type SerialParam ¶
type SerialParam struct {
SerialNr EBoardSerial `json:"serialnr,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.