Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleHandshake ¶
func HandleHandshake(rw http.ResponseWriter, r *http.Request, s *Server)
HandleHandshake handles incoming WebSocket handshake requests. It upgrades the HTTP connection to the WebSocket protocol and stores the [client].
During the handshake, the Server performs authentication by sending an HTTP POST request to the endpoint specified in the AUTH_URL environment variable. The request body contains the session id, extracted from the client's cookie.
The authentication endpoint must validate the session by looking it up in the session database. If valid, the endpoint must return the corresponding player id, which is then associated with the client connection.
Types ¶
type Server ¶
type Server struct {
// Incomming client events.
ExternalBus chan event.ExternalEvent
// Incomming server events.
InternalBus chan event.InternalEvent
// contains filtered or unexported fields
}
Server stores the subscribtion map, handles client registration, unregistration, and routes the incomming events into the corresponding handlers.