Documentation ¶
Index ¶
- Constants
- func BroadcastMessage(messageType string, message interface{})
- func DisconnectClient(identifier string)
- func ReconnectClient(identifier string)
- func ServeWs(context echo.Context)
- type Bot
- type Client
- type Engine
- type Room
- func (r *Room) AddBot(identifier string, difficulty int)
- func (r *Room) AddPlayer(identifier string)
- func (r *Room) GetPlayer(identifier string) map[string]string
- func (r *Room) GetPlayers() map[string]interface{}
- func (r *Room) RemoveAllBots()
- func (r *Room) RemoveBot(identifier string)
- func (r *Room) RemoveBots(count int)
- func (r *Room) RemovePlayer(identifier string)
- func (r *Room) Run()
- func (r *Room) SendMessage(messageType string, message interface{}) bool
- func (r *Room) StartBotCountdown()
- func (r *Room) StopBotCountdown()
- type SocketHub
Constants ¶
View Source
const ( WRITE_WAIT = 10 * time.Second PONG_WAIT = 60 * time.Second PING_PERIOD = (PONG_WAIT * 9) / 10 MAX_MESSAGE_SIZE = 1024 * 1024 )
View Source
const ( ROOM_EXPIRY_TIME = 3600 * 24 TYPE_LEFT_ROOM = "LEFT_ROOM" // Sent to user after successful room leaving TYPE_JOINED_ROOM = "JOINED_ROOM" TYPE_MAX_PLAYERS = 5 TYPE_PLAYER_JOINED_ROOM = "PLAYER_JOINED_ROOM" TYPE_PLAYER_LEFT_ROOM = "PLAYER_LEFT_ROOM" TYPE_PLAYER_COMPLETED_GAME = "PLAYER_COMPLETED_GAME" TYPE_START_COUNTDOWN = "START_COUNTDOWN" TYPE_STOP_COUNTDOWN = "STOP_COUNTDOWN" TYPE_TICK_COUNTDOWN = "TICK_COUNTDOWN" TYPE_START_WAIT_COUNTDOWN = "START_WAIT_COUNTDOWN" TYPE_STOP_WAIT_COUNTDOWN = "STOP_WAIT_COUNTDOWN" TYPE_TICK_WAIT_COUNTDOWN = "TICK_WAIT_COUNTDOWN" TYPE_START_GAME = "START_GAME" TYPE_FINISH_GAME = "FINISH_GAME" TYPE_UPDATE_PLAYERS_DATA = "UPDATE_PLAYERS_DATA" TYPE_MIN_BOTS = 1 TYPE_MAX_BOTS = 3 WAIT_SECONDS = 10 // How many seconds should the room count down for other players FINISH_GAME_SECONDS = 4 * 60 // How many seconds must pass before the game automatically closes )
View Source
const ( TYPE_CONNECTED = "CONNECTED" // Used after successful connection to the websocket server TYPE_ERROR = "ERROR" // Generic error type for any unsuccessful action TYPE_ONLINE_GAME_PLAYERS_SET = "ONLINE_GAME_PLAYERS_SET" TYPE_ONLINE_GAME_COUNTDOWN_STARTED = "TYPE_ONLINE_GAME_COUNTDOWN_STARTED" TYPE_ONLINE_GAME_COUNTDOWN_STOPPED = "TYPE_ONLINE_GAME_COUNTDOWN_STOPPED" TYPE_ONLINE_GAME_COUNTDOWN_SET = "TYPE_ONLINE_GAME_COUNTDOWN_SET" TYPE_ONLINE_GAME_RESET = "TYPE_ONLINE_GAME_RESET" )
View Source
const ( CODE_RECONNECT = 5001 CODE_DISCONNECT = 5000 )
View Source
const TYPE_BOT_EASY = 1
View Source
const TYPE_BOT_HARD = 3
View Source
const TYPE_BOT_MEDIUM = 2
View Source
const TYPE_BOT_SUPER_HARD = 4
View Source
const TYPE_BOT_WPM_MULTIPLIER = 25
Variables ¶
This section is empty.
Functions ¶
func BroadcastMessage ¶
func BroadcastMessage(messageType string, message interface{})
func DisconnectClient ¶
func DisconnectClient(identifier string)
func ReconnectClient ¶
func ReconnectClient(identifier string)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) SendMessage ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) GetOnlineRoomData ¶
GetOnlineRoomData returns details about an online room that hasn't started yet It'll be used to display player counts badge and room info in the online sidebar
func (*Engine) RemoveRoom ¶
type Room ¶
type Room struct { Id string Players map[string]bool Bots map[string]Bot // contains filtered or unexported fields }
func (*Room) GetPlayers ¶
Returns a slice with players in this room along with all the data
func (*Room) RemoveAllBots ¶
func (r *Room) RemoveAllBots()
func (*Room) RemoveBots ¶
Remove a given number of bots from the room (if exist)
func (*Room) RemovePlayer ¶
Removes player from the room
func (*Room) SendMessage ¶
Sends a message to the members of this room
func (*Room) StartBotCountdown ¶
func (r *Room) StartBotCountdown()
func (*Room) StopBotCountdown ¶
func (r *Room) StopBotCountdown()
Click to show internal directories.
Click to hide internal directories.