websocket

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package websocket provides the http handler, client and hub for managing the websocket connections of clients using rfoutlet. This is both used to react on commands of a single client as well as to broadcast updates to all clients so that state changes are immediately visible to everybody.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(hub *Hub, queue chan<- command.Command) gin.HandlerFunc

Handler accepts websocket connections and creates a clients to handle them.

Types

type Hub

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

Hub acts as a central registry for connected websocket clients and can be used to broadcast messages to everyone.

func NewHub

func NewHub() *Hub

NewHub creates a new hub for handling communicating between connected websocket clients.

func (*Hub) Broadcast

func (h *Hub) Broadcast(msg []byte)

Broadcast broadcasts msg to all connected clients.

func (*Hub) Run

func (h *Hub) Run(stopCh <-chan struct{})

Run runs the control loop. If stopCh is closed, the hub will disconnect all clients and stop the control loop.

func (*Hub) Send

func (h *Hub) Send(client *client, msg []byte)

Send sends a message to a specific client.

Jump to

Keyboard shortcuts

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