websocket

package
v0.0.0-...-8aa1adc Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(notification *PushNotification) error

Broadcast sends a PushNotification to all connected clients

func PushTo

func PushTo(notification *PushNotification, subscriptionID string)

PushTo sends the PushNotification to the subscribed clients

func SubscribeLiveChat

func SubscribeLiveChat() http.Handler

SubscribeLiveChat is a handler to accept web socket subscriptions for a live chat

Types

type Client

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

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

type Hub

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

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

type PushNotification

type PushNotification struct {
	Type string                 `json:"type"`
	Data map[string]interface{} `json:"data,omitempty"`
}

PushNotification is a message format that tells the client the type of message and the content

Jump to

Keyboard shortcuts

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