hub

package
v0.0.0-...-9e083ad Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// Buffered channel of outbound messages.
	Send chan request.URLRequest
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

func ServeWs

func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request) *Client

ServeWs handles websocket requests from the peer.

type Hub

type Hub struct {
	// Registered clients.
	Clients map[*Client]bool

	// Broadcast message to workers.
	Broadcast chan request.URLRequest

	// Receive message from workers.
	Receive chan []byte

	// Register requests from the clients.
	Register chan *Client

	// Unregister requests from clients.
	Unregister chan *Client
}

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub() *Hub

NewHub returns a new hub

func (*Hub) Run

func (h *Hub) Run(receiveHandler func([]byte))

Run runs rub

Jump to

Keyboard shortcuts

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