Documentation
¶
Index ¶
- Constants
- func BotHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
- func CreateHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
- func HomeHandler(w http.ResponseWriter, r *http.Request)
- func IdExists(rooms Storage, id string) bool
- func JoinHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
- func LobbyHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
- func MakeId(roomStorage Storage) string
- func MakePin(room string, roomStorage Storage) string
- func MakeRouter() *mux.Router
- func WSHandshake(w http.ResponseWriter, r *http.Request, roomStorage Storage)
- type ReqBody
- type Storage
Constants ¶
const CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
All the chars that MakePin can utilize
Variables ¶
This section is empty.
Functions ¶
func BotHandler ¶
func BotHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
func CreateHandler ¶
func CreateHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
CreateHandler creates a room. Sends back a path with an id to go to along with leader permissions. Redirects user back to root path with a message if there is an error / problems. BUG: CreateHandler doesn't handle rooms with special character names
func HomeHandler ¶
func HomeHandler(w http.ResponseWriter, r *http.Request)
HomeHandler send the index.html page at root path
func JoinHandler ¶
func JoinHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
JoinHandler handles POST requests to join a game. Redirects users back to root with a message if there is an error. Sends back a path with an id to go to to if there is no error.
func LobbyHandler ¶
func LobbyHandler(w http.ResponseWriter, r *http.Request, roomStorage Storage)
Handler that serves game file Create and Join Handler will route here Redirects people who reach here by URL back to Join to be stored in context
func MakeRouter ¶
MakeRouter creates a router that will handle the routes for Chain Reaction.
func WSHandshake ¶
func WSHandshake(w http.ResponseWriter, r *http.Request, roomStorage Storage)
Creates a websocket connection and starts the hub and client goroutines Might be changed to POST if a websocket server and http server are separated. Function couples the server and the websocket together so two servers are not needed Is in charge of stopping hub server
Types ¶
type ReqBody ¶
type ReqBody struct {
Pin, Room, Players, Username string
}
Valid request information that a user can send It is stored in the context
func DecodeBody ¶
func DecodeBody(data io.ReadCloser) (*ReqBody, error)
Decode Json message from HTTP Request. Prevents strange values.