Documentation ¶
Index ¶
- Constants
- Variables
- func AiFromJson(data io.Reader) (*Ai, *AppError)
- func ComparePassword(hash string, password string) bool
- func GameStatsToJson(gs *Game) string
- func GameStatssToJson(gs []*GameStats) string
- func GamesToJson(g []*Game) string
- func GetMillis() int64
- func HashPassword(password string) string
- func IsLower(s string) bool
- func IsValidEmail(email string) bool
- func IsValidUsername(s string) bool
- func MapFromJson(data io.Reader) map[string]string
- func MapToJson(objmap map[string]string) string
- func MovesToJson(m []*Move) string
- func NewID() string
- func NewWebSocketClient(url, authID string) (*WebSocketClient, *AppError)
- func PlayerToJson(p []*Player) string
- func PlayersToJson(p []*Player) string
- func StringInterfaceFromJson(data io.Reader) map[string]interface{}
- func StringInterfaceToJson(objmap map[string]interface{}) string
- func TokensToJson(tokens []*Token) string
- type Ai
- type AppError
- type Config
- type Game
- type GameStats
- type Move
- type Player
- type ServerConfiguration
- type SqlConfiguration
- type Token
- type WebSocketClient
- type WebSocketEvent
- type WebSocketMessage
- type WebSocketRequest
- type WebSocketResponse
Constants ¶
View Source
const ( HEADER_FORWARDED_PROTO = "X-Forwarded-Proto" HEADER_FORWARDED = "X-Forwarded-For" HEADER_REAL_IP = "X-Real-IP" HEADER_REQUEST_ID = "X-Request-ID" HEADER_AUTH = "Authorization" HEADER_BEAR = "Bear" STATUS_OK = "OK" STATUS_FAIL = "FAIL" )
View Source
const ( MAX_NUMLINES = 19 MIN_NUMLINES = 5 WHITE = 1 BLACK = 2 )
View Source
const ( DEFAULT_LOCALE = "en" MIN_PASSWORD_LENGTH = 5 MAX_PASSWORD_LENGTH = 64 MIN_USERNAME_LENGTH = 4 MAX_USERNAME_LENGTH = 24 )
View Source
const ( WEBSOCKET_EVENT_MATCHMAKING_START = "matchmaking_start" WEBSOCKET_EVENT_MATCHMAKING_CANCEL = "matchmaking_cancel" WEBSOCKET_EVENT_MATCHMAKING_FOUND = "matchmaking_found" WEBSOCKET_EVENT_GAME_MOVE = "game_move" WEBSOCKET_EVENT_HELLO_WORLD = "hello_world" )
View Source
const (
ID_LENGTH = 24
)
View Source
const (
TOKEN_DURATION = 1000 * 60 * 60 * 24 * 30 // 30 days
)
View Source
const (
WEBSOCKET_URL = "/api/websocket"
)
Variables ¶
View Source
var CurrentVersion string = versions[0]
Functions ¶
func ComparePassword ¶
func GameStatsToJson ¶
func GameStatssToJson ¶
func GamesToJson ¶
func HashPassword ¶
func IsValidEmail ¶
func IsValidUsername ¶
func MovesToJson ¶
func NewWebSocketClient ¶
func NewWebSocketClient(url, authID string) (*WebSocketClient, *AppError)
func PlayerToJson ¶
func PlayersToJson ¶
func StringInterfaceFromJson ¶
func StringInterfaceToJson ¶
func TokensToJson ¶
Types ¶
type AppError ¶
func NewAppError ¶
type Config ¶
type Config struct { ServerConfiguration ServerConfiguration SqlConfiguration SqlConfiguration }
func ConfigFromJson ¶
type Game ¶
type Game struct { ID string `json:"id"` IDBlack string `json:"id_black"` IDWhite string `json:"id_white"` Board string `json:"board"` NumLines uint `json:"numlines"` Turn uint `json:"turn"` CreateAt int64 `json:"create_at"` UpdateAt int64 `json:"update_at"` DeleteAt int64 `json:"delete_at"` Finished bool `json:"finished"` }
func GameFromJson ¶
type Move ¶
type Move struct { PlayerID string `json:"player_id"` GameID string `json:"game_id"` ID string `json:"id"` X uint `json:"move_x"` Y uint `json:"move_y"` CreateAt int64 `json:"create_at"` }
func MoveFromJson ¶
func MovesFromJson ¶
type Player ¶
type Player struct { ID string `json:"id"` CreateAt int64 `json:"create_at"` UpdateAt int64 `json:"update_at"` DeleteAt int64 `json:"delete_at"` Username string `json:"username"` Password string `json:"password,omitempty"` Email string `json:"email"` AllowStats bool `json:"allow_stats"` Locale string `json:"locale"` IsAdmin bool `json:"is_admin,omitempty"` }
func PlayerFromJson ¶
type ServerConfiguration ¶
type ServerConfiguration struct {
ListenPort string
}
type SqlConfiguration ¶
type Token ¶
type Token struct { ID string `json:"id"` CreateAt int64 `json:"create_at"` ExpiresAt int64 `json:"expires_at"` LastActivityAt int64 `json:"last_activity_at"` PlayerID string `json:"player_id"` DeviceID string `json:"device_id"` Roles string `json:"roles"` IsOAuth bool `json:"is_oauth"` }
func TokenFromJson ¶
type WebSocketClient ¶
type WebSocketClient struct { Url string Connection *websocket.Conn AuthID string Sequence int64 EventChannel chan *WebSocketEvent ResponseChannel chan *WebSocketResponse }
func (*WebSocketClient) Close ¶
func (w *WebSocketClient) Close()
func (*WebSocketClient) Connect ¶
func (w *WebSocketClient) Connect() *AppError
func (*WebSocketClient) Listen ¶
func (w *WebSocketClient) Listen()
func (*WebSocketClient) SendMessage ¶
func (w *WebSocketClient) SendMessage(action string, data map[string]interface{})
type WebSocketEvent ¶
type WebSocketEvent struct { PlayerID string `json:"player_id"` GameID string `json:"game_id"` Event string `json:"event"` Data map[string]interface{} `json:"data"` }
func NewWebSocketEvent ¶
func NewWebSocketEvent(playerID, gameID, event string) *WebSocketEvent
func WebSocketEventFromJson ¶
func WebSocketEventFromJson(data io.Reader) *WebSocketEvent
func (*WebSocketEvent) Add ¶
func (w *WebSocketEvent) Add(key string, value interface{})
func (*WebSocketEvent) IsValid ¶
func (w *WebSocketEvent) IsValid() bool
func (*WebSocketEvent) ToJson ¶
func (w *WebSocketEvent) ToJson() string
type WebSocketMessage ¶
type WebSocketRequest ¶
type WebSocketRequest struct { Sequence int64 `json:"sequence"` Action string `json:"action"` Data map[string]interface{} `json:"data"` Token *Token `json:"-"` }
func WebSocketRequestFromJson ¶
func WebSocketRequestFromJson(data io.Reader) *WebSocketRequest
func (*WebSocketRequest) ToJson ¶
func (w *WebSocketRequest) ToJson() string
type WebSocketResponse ¶
type WebSocketResponse struct { Status string `json:"status"` ReplySequence int64 `json:"reply_sequence,omitempty"` Data map[string]interface{} `json:"data,omitempty"` Error *AppError `json:"error,omitempty"` }
func NewWebSocketError ¶
func NewWebSocketError(seqReply int64, err *AppError) *WebSocketResponse
func NewWebSocketResponse ¶
func NewWebSocketResponse(status string, replySequence int64, data map[string]interface{}) *WebSocketResponse
func WebSocketResponseFromJson ¶
func WebSocketResponseFromJson(data io.Reader) *WebSocketResponse
func (*WebSocketResponse) Add ¶
func (w *WebSocketResponse) Add(key string, value interface{})
func (*WebSocketResponse) IsValid ¶
func (w *WebSocketResponse) IsValid() bool
func (*WebSocketResponse) ToJson ¶
func (w *WebSocketResponse) ToJson() string
Click to show internal directories.
Click to hide internal directories.