Documentation ¶
Overview ¶
Package server contains controller and client logic
Index ¶
Constants ¶
const ( WsRequestActionSelectCard WsRequestAction = "select" WsRequestActionReveal = "reveal" WsRequestActionReset = "reset" WsRequestActionDeck = "deck" WsRequestActionTopic = "topic" WsRequestActionUsername = "username" )
WsRequestAction constants
const UsernameMaxLength = 25
UsernameMaxLength is the maximum number of characters allowed in a username
Variables ¶
var ErrInvalidUsername = errors.New("server: invalid username entered")
ErrInvalidUsername is an error when the username does not match criteria
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client represents a user connected via websocket
func (*Client) CloseChannel ¶
func (c *Client) CloseChannel()
CloseChannel will close the send channel
func (*Client) RemoteAddr ¶
RemoteAddr returns the remote address (IP + port) of the client
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main object that can be used to return an *http.ServeMux object.
func (*Server) HandleWsRequest ¶
HandleWsRequest handles requests that came in from a web socket connection via Client
func (*Server) ListenForEvents ¶
ListenForEvents will listen for various events like when to destroy a game, and when to disconnect the server.
type WsConn ¶
type WsConn interface { Close() error ReadJSON(v interface{}) error RemoteAddr() net.Addr SetPongHandler(func(appDate string) error) SetReadDeadline(t time.Time) error SetReadLimit(limit int64) SetWriteDeadline(t time.Time) error WriteJSON(v interface{}) error WriteMessage(messageType int, data []byte) error }
WsConn is an interface which implements a subset of the available methods in *websocket.Conn
type WsRequest ¶
type WsRequest struct { Action WsRequestAction `json:"action"` Card int `json:"card"` Deck string `json:"deck"` Room string `json:"room"` Token string `json:"token"` Value string `json:"value"` }
WsRequest is data that was read from a web socket connection
type WsRequestAction ¶
type WsRequestAction string
WsRequestAction is a type for representing a web socket action