httphandler

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

func SetUpUpdatesList

func SetUpUpdatesList() error

Types

type HttpHandlerUtils

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

func GetUtils

func GetUtils() *HttpHandlerUtils

func (*HttpHandlerUtils) SetErrorLogger

func (u *HttpHandlerUtils) SetErrorLogger(logger *log.Logger)

func (*HttpHandlerUtils) SetInfoLogger

func (u *HttpHandlerUtils) SetInfoLogger(logger *log.Logger)

type Requests

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

type Requests is used to "pre-process" the HTTP requests from the web client before passing them to the system

func GetRequestsInstance

func GetRequestsInstance() *Requests

func (*Requests) AcceptRoomInvitation

func (rq *Requests) AcceptRoomInvitation(w http.ResponseWriter, r *http.Request)

AcceptRoomInvitation() is the handler for the HTTP client requests to accept an invitation to a game session

func (*Requests) CreateRoom

func (rq *Requests) CreateRoom(w http.ResponseWriter, r *http.Request)

CreateRoom() is the handler for the HTTP client requests to create a game session

func (*Requests) DeclineRoomInvitation

func (rq *Requests) DeclineRoomInvitation(w http.ResponseWriter, r *http.Request)

DeclineRoomInvitation() is the handler for the HTTP client requests to decline an invitation to a game session

func (*Requests) GetGamesList

func (rq *Requests) GetGamesList(w http.ResponseWriter, r *http.Request)

GetGamesList() returns the list of games currently available. Each items contains the game ID, game name, and the maximum number of players.

func (*Requests) InviteToRoom

func (rq *Requests) InviteToRoom(w http.ResponseWriter, r *http.Request)

InviteToRoom() is the handler for the HTTP client requests to invite a particular player to an existing game session

func (*Requests) LeaveRoom

func (rq *Requests) LeaveRoom(w http.ResponseWriter, r *http.Request)

LeaveRoom() is the handler for the HTTP client requests to leave a specific room

func (*Requests) LogIn

func (rq *Requests) LogIn(w http.ResponseWriter, r *http.Request)

LogIn() is the handler for the HTTP client user log in requests Allowed methods: - POST

func (*Requests) LogOut

func (rq *Requests) LogOut(w http.ResponseWriter, r *http.Request)

LogOut() is the handler for the HTTP client user log out requests

func (*Requests) SetUserSessionsHandle

func (rq *Requests) SetUserSessionsHandle(us *usersessions.UserSessions)

Set the handler for the UserSessions module. This function should not allow re-assigning the interface handle from other modules.

func (*Requests) SignUp

func (rq *Requests) SignUp(w http.ResponseWriter, r *http.Request)

SignUp() is the handler for the HTTP client user sign up requests. The handler does not validate the user input apart from ensuring the proper data types. Allowed methods: - POST

func (*Requests) StartGame

func (rq *Requests) StartGame(w http.ResponseWriter, r *http.Request)

StartGame() is the handler for the HTTP client requests to start a specific game session

type UpdateFetcher

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

type UpdateFetcher is used for serving room info, notifications, and game state update requests

func GetUpdateFetcherInstance

func GetUpdateFetcherInstance() *UpdateFetcher

func (*UpdateFetcher) GetGameStateUpdate

func (uf *UpdateFetcher) GetGameStateUpdate(w http.ResponseWriter, r *http.Request)

getGameStateUpdate() sends back a game session update (for a specific session), if there is an update. Otherwise returns a "no updates" response

func (*UpdateFetcher) GetNotifications

func (uf *UpdateFetcher) GetNotifications(w http.ResponseWriter, r *http.Request)

GetNotifications() sends back all the game session invitations for a user

func (*UpdateFetcher) GetRoomInfoUpdate

func (uf *UpdateFetcher) GetRoomInfoUpdate(w http.ResponseWriter, r *http.Request)

GetRoomInfoUpdate() sends back a room update, if there is an update. Otherwise returns a "no updates" response

func (*UpdateFetcher) SetUserSessionsHandle

func (uf *UpdateFetcher) SetUserSessionsHandle(us *usersessions.UserSessions)

Set the handler for the UserSessions interface. This function should not allow re-assigning the interface handle from other modules.

type Updates

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

Update holds the game session updates, game instance updates, and game session invitations.

type UpdatesHandler

type UpdatesHandler struct {
}

UpdatesHandler is the implementation of the UpdatesHandler interface of the client communication module

func GetUpdateReceiver

func GetUpdateReceiver() *UpdatesHandler

func (*UpdatesHandler) HandlerType

func (uh *UpdatesHandler) HandlerType() string

HandlerType() returns the connection type used

func (*UpdatesHandler) SendRoomInvitation

func (uh *UpdatesHandler) SendRoomInvitation(userId int, lnSessId int, inv clientcomm.RoomInvitation)

SendRoomInvitation() updates a user with game session invitation

func (*UpdatesHandler) UpdateGameState

func (uh *UpdatesHandler) UpdateGameState(userId int, gameState clientcomm.GameState)

UpdateGameInstanceState() updates a user with a game instance state

func (*UpdatesHandler) UpdateRoomInfo

func (uh *UpdatesHandler) UpdateRoomInfo(userId int, update clientcomm.RoomInfo)

UpdateRoomInfo() updates a user with a game session state

type UpdatesList

type UpdatesList struct {
	sync.Mutex
	// contains filtered or unexported fields
}

UpdatesList holds the pending updates for each user that has a login session associated with the HTTP connection (i.e. they have logged in via a client using HTTP). Each login session may have multiple gaming sessions and gaming sessions invites associated with it. Each update is associated with a key, which is the user id.

Jump to

Keyboard shortcuts

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