Documentation ¶
Overview ¶
The package serves as an interface to incoming client requests (excluding user requests) and distributes to the updates to the clients based on their login session connection type (such as HTTP, TCP, etc.)
Index ¶
- func Init()
- func SetErrorLogger(errorLog *log.Logger)
- func SetInfoLogger(infoLog *log.Logger)
- type ClientComm
- func (cc *ClientComm) AcceptRoomInvitation(req StdReqInfo) error
- func (cc *ClientComm) CreateRoom(userId int, lnSessId int, un string) (int, error)
- func (cc *ClientComm) DeclineRoomInvitation(req StdReqInfo) error
- func (cc *ClientComm) GetGamesList() []GameInfo
- func (cc *ClientComm) InviteToRoom(req StdReqInfo, inviteeId int, inviteeUn string) error
- func (cc *ClientComm) LeaveRoom(req StdReqInfo)
- func (cc *ClientComm) RegisterLnSess(userId int, lnSessId int, connType string)
- func (cc *ClientComm) StartGame(req StdReqInfo, gameId int) error
- func (cc *ClientComm) UnregisterLnSess(userId int, lnSessId int)
- type ClientCommLogger
- type ConnTable
- type GameInfo
- type GameState
- type IUpdatesHandler
- type LnSessInfo
- type RoomInfo
- type RoomInvitation
- type RoomInvite
- type StdReqInfo
- type UpdateUser
- func (iu *UpdateUser) AddUpdatesHandler(uh IUpdatesHandler)
- func (iu *UpdateUser) SendInvitation(userId int, roomId int, hostUn string)
- func (iu *UpdateUser) UpdateGameState(userId int, roomId int, gameState igame.GameState)
- func (iu *UpdateUser) UpdateRoomInfo(userId int, state boardelicious.RoomInfo)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetErrorLogger ¶
func SetInfoLogger ¶
Types ¶
type ClientComm ¶
type ClientComm struct { }
type ClientComm is the interface for the incoming client requests
func (*ClientComm) AcceptRoomInvitation ¶
func (cc *ClientComm) AcceptRoomInvitation(req StdReqInfo) error
AcceptInvitation() accept an invitation to a game session
func (*ClientComm) CreateRoom ¶
CreateRoom() create a new game session
func (*ClientComm) DeclineRoomInvitation ¶
func (cc *ClientComm) DeclineRoomInvitation(req StdReqInfo) error
DeclineInvitation() decline an invitation to a room
func (*ClientComm) GetGamesList ¶
func (cc *ClientComm) GetGamesList() []GameInfo
GetGamesList returns the list of game parameters
func (*ClientComm) InviteToRoom ¶
func (cc *ClientComm) InviteToRoom(req StdReqInfo, inviteeId int, inviteeUn string) error
InviteToRoom() invite a player to a specific game session
func (*ClientComm) LeaveRoom ¶
func (cc *ClientComm) LeaveRoom(req StdReqInfo)
LeaveSession() leave an existing game session
func (*ClientComm) RegisterLnSess ¶
func (cc *ClientComm) RegisterLnSess(userId int, lnSessId int, connType string)
RegisterLnSess() add login session details to the connection table
func (*ClientComm) StartGame ¶
func (cc *ClientComm) StartGame(req StdReqInfo, gameId int) error
StartGame() start the game
func (*ClientComm) UnregisterLnSess ¶
func (cc *ClientComm) UnregisterLnSess(userId int, lnSessId int)
UnregisterLnSess() remove login session details from the connection table
type ClientCommLogger ¶
type ClientCommLogger struct {
// contains filtered or unexported fields
}
type ConnTable ¶
ConnTable holds the information associating rooms with login sessions and connection types. The room entries are grouped together by the user
type GameState ¶
type GameState struct { RoomId int LnSessId int Ints map[string]int Strings map[string]string Bools map[string]bool IntSlice map[string][]int StringSlice map[string][]string BoolSlice map[string][]bool }
An alias for rooms.GameState
type IUpdatesHandler ¶
type IUpdatesHandler interface { HandlerType() string SendRoomInvitation(userId int, lnSessId int, inv RoomInvitation) UpdateRoomInfo(userId int, update RoomInfo) UpdateGameState(userId int, gameState GameState) }
UpdateHandler sends out updates to a user
type LnSessInfo ¶
Each login session is associated with a certain connection type (E.g., HTTP, TCP, etc.)
type RoomInfo ¶
type RoomInfo struct { // ActiveUsers only holds the usernames; ids are not included ActiveUsers []string RoomId int GameActive bool LnSessId int }
Additional details are added to this type, compared to rooms.RoomInfo
type RoomInvitation ¶
Room invitation types: active - set for new invitations used - set for when an invitation needs to be cleared in the game client (e.g., it was accepted or rejected)
type RoomInvite ¶
type RoomInvite struct {
InviteeUn string
}
type StdReqInfo ¶
type UpdateUser ¶
type UpdateUser struct {
// contains filtered or unexported fields
}
func GetUpdateUser ¶
func GetUpdateUser() *UpdateUser
func (*UpdateUser) AddUpdatesHandler ¶
func (iu *UpdateUser) AddUpdatesHandler(uh IUpdatesHandler)
Set the handler for an UpdatesHandler interface. This function should not allow re-assigning the interface handle for the same connection from other modules.
func (*UpdateUser) SendInvitation ¶
func (iu *UpdateUser) SendInvitation(userId int, roomId int, hostUn string)
SendInvitation() send a room invitation to a player. An invitation is sent for each active login session so that it appears in all game clients.
func (*UpdateUser) UpdateGameState ¶
func (iu *UpdateUser) UpdateGameState(userId int, roomId int, gameState igame.GameState)
UpdateGameState() send the new game state to a player.
func (*UpdateUser) UpdateRoomInfo ¶
func (iu *UpdateUser) UpdateRoomInfo(userId int, state boardelicious.RoomInfo)
UpdateRoomInfo() send the new game session state to a player.