ws

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

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.

func NewServer

func NewServer(ch *amqp091.Channel) *Server

NewServer initializes the Server fields and adds the default "hub" record in the subscribtion map.

func (*Server) Run

func (s *Server) Run()

Run accepts events from the Server channels and calls the corresponding event handlers.

Jump to

Keyboard shortcuts

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