websocket

package
v0.0.0-...-810d5f5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Context = `WEBSERVER/WEBSOCKET`

Context to use when logging

View Source
const ContextBroadcast = "WEBSOCKET/BROADCAST"

ContextBroadcast used to identify the broadcast server in logging

View Source
const DeadlinePong = 3 * time.Minute

DeadlinePong to send after a ping request in the control message

Variables

This section is empty.

Functions

func Endpoint

func Endpoint(endpoint string, handler func(string, url.Values, <-chan []byte, chan<- []byte, chan<- error, <-chan bool))

Endpoint handles a HTTP request and upgrades it, giving the user a channel to receive messages down and a reply channel to send messages to the websocket.

Types

type Broadcast

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

Broadcast for sending messages to channels subscribing to events here

func NewBroadcast

func NewBroadcast() *Broadcast

NewBroadcast, creating a new map and new counter for messages and set up the server that handles new subscriptions.

func (Broadcast) Broadcast

func (broadcast Broadcast) Broadcast(message []byte)

func (Broadcast) BroadcastJson

func (broadcast Broadcast) BroadcastJson(content interface{})

func (*Broadcast) Shutdown

func (broadcast *Broadcast) Shutdown()

Shutdown the broadcast, closing the inner worker and setting the struct to nil

func (Broadcast) Subscribe

func (broadcast Broadcast) Subscribe(messages chan []byte) uint64

Subscribe to the broadcast, with a new channel receiving messages being sent

func (Broadcast) Unsubscribe

func (broadcast Broadcast) Unsubscribe(cookie uint64)

Jump to

Keyboard shortcuts

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