api

package
v0.0.0-...-96e6067 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WRITE_WAIT  = 5 * time.Second
	PONG_WAIT   = 10 * time.Second
	PING_PERIOD = (PONG_WAIT * 9) / 10
	MAX_SIZE    = 512
	REDIS_WAIT  = 30 * time.Second
)

Variables

This section is empty.

Functions

func ApiAdminRequired

func ApiAdminRequired(h func(*Session, http.ResponseWriter, *http.Request)) http.Handler

func ApiHandler

func ApiHandler(h func(*Session, http.ResponseWriter, *http.Request)) http.Handler

func ApiPlayerRequired

func ApiPlayerRequired(h func(*Session, http.ResponseWriter, *http.Request)) http.Handler

func ApiWebSocketHandler

func ApiWebSocketHandler(wh func(*model.WebSocketRequest) (map[string]interface{}, *model.AppError)) *webSocketHandler

func CreatePlayer

func CreatePlayer(player *model.Player) (*model.Player, *model.AppError)

func GetAllGames

func GetAllGames() ([]*model.Game, *model.AppError)

func GetAllMoves

func GetAllMoves() ([]*model.Move, *model.AppError)

func GetAllPlayers

func GetAllPlayers() ([]*model.Player, *model.AppError)

func GetGame

func GetGame(id string) (*model.Game, *model.AppError)

func GetGameMoves

func GetGameMoves(gameID string) ([]*model.Move, *model.AppError)

func GetIpAddress

func GetIpAddress(r *http.Request) string

func GetMove

func GetMove(id string) (*model.Move, *model.AppError)

func GetPlayer

func GetPlayer(id string) (*model.Player, *model.AppError)

func GetPlayerByUsername

func GetPlayerByUsername(username string) (*model.Player, *model.AppError)

func GetPlayerGames

func GetPlayerGames(id string) ([]*model.Game, *model.AppError)

func GetProtocol

func GetProtocol(r *http.Request) string

func GetToken

func GetToken(id string) *model.Token

func Handle404

func Handle404(w http.ResponseWriter, r *http.Request)

func InitAdmin

func InitAdmin()

func InitAi

func InitAi()

func InitApi

func InitApi()

func InitGame

func InitGame()

func InitMove

func InitMove()

func InitPlayer

func InitPlayer()

func InitPlayerAuth

func InitPlayerAuth()

func InitWebSocket

func InitWebSocket()

func Login

func Login(username, password string) (*model.Token, *model.AppError)

func LoginByTokenID

func LoginByTokenID(tokenID, username string) (*model.Token, *model.AppError)

func Logout

func Logout(token *model.Token) *model.AppError

func NewInvalidParamError

func NewInvalidParamError(location string, name string) *model.AppError

func NewInvalidWebSocketParamError

func NewInvalidWebSocketParamError(action string, name string) *model.AppError

func NewServer

func NewServer()

func Publish

func Publish(message *model.WebSocketEvent)

func StartServer

func StartServer()

func StopServer

func StopServer()

func UpdatePlayer

func UpdatePlayer(player *model.Player) (*model.Player, *model.AppError)

Types

type Routes

type Routes struct {
	Root       *mux.Router
	Players    *mux.Router
	NeedPlayer *mux.Router
	Games      *mux.Router
	NeedGame   *mux.Router
	Moves      *mux.Router
	Ai         *mux.Router
	AiNeedGame *mux.Router
	Admin      *mux.Router
	WebSocket  *WebSocketRouter
}
var BaseRoutes *Routes

type Server

type Server struct {
	Store  store.Store
	Router *mux.Router
}
var Srv *Server

type Session

type Session struct {
	RequestID string
	IpAddress string
	Path      string
	Err       *model.AppError
	RootUrl   string
	Token     *model.Token
}

func (*Session) CheckAdminRequired

func (s *Session) CheckAdminRequired()

func (*Session) CheckPlayerRequired

func (s *Session) CheckPlayerRequired()

func (*Session) IsAdmin

func (s *Session) IsAdmin() bool

func (*Session) SetInvalidParam

func (s *Session) SetInvalidParam(location string, name string)

type WebConn

type WebConn struct {
	WebSocket *websocket.Conn
	Send      chan model.WebSocketMessage
	TokenID   string
	PlayerID  string
}

func NewWebConn

func NewWebConn(s *Session, ws *websocket.Conn) *WebConn

type WebHub

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

func (*WebHub) Broadcast

func (h *WebHub) Broadcast(message *model.WebSocketEvent)

func (*WebHub) Register

func (h *WebHub) Register(webConn *WebConn)

func (*WebHub) Start

func (h *WebHub) Start()

func (*WebHub) Stop

func (h *WebHub) Stop()

func (*WebHub) Unregister

func (h *WebHub) Unregister(webConn *WebConn)

type WebSocketRouter

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

func NewWebSocketRouter

func NewWebSocketRouter() *WebSocketRouter

func (*WebSocketRouter) Handle

func (wr *WebSocketRouter) Handle(action string, handler *webSocketHandler)

func (*WebSocketRouter) ReturnWebSocketError

func (wr *WebSocketRouter) ReturnWebSocketError(conn *WebConn, r *model.WebSocketRequest, err *model.AppError)

func (*WebSocketRouter) ServeWebSocket

func (wr *WebSocketRouter) ServeWebSocket(conn *WebConn, r *model.WebSocketRequest)

Jump to

Keyboard shortcuts

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