ws

package
v0.0.0-...-5c7a00c Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeWS

func ServeWS(hub *Hub) http.HandlerFunc

ServeWS will handle the websocket connection

Types

type Connection

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

Connection represents a websocket connection

type Hub

type Hub struct {
	Rooms      map[string]map[*Connection]bool
	Broadcast  chan Message
	Register   chan Subscription
	Unregister chan Subscription
}

Hub holds the websocket rooms and handels subscription

func (*Hub) Run

func (h *Hub) Run()

Run will run the hub

type Message

type Message struct {
	Data []byte
	Room string
}

Message represents a websocket message

type Subscription

type Subscription struct {
	Hub  *Hub
	Conn *Connection
	Room string
}

Subscription represents a websocket client subscription

Jump to

Keyboard shortcuts

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