sockets

package
v0.0.0-...-2e57706 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package sockets encapsulates all of the Websocket communication. It's part of the framework/drivers layer.

Index

Constants

View Source
const ConnPollPeriod = 60 * time.Second

Variables

View Source
var AllowedOrigins = []string{}

Functions

func ServeWS

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

ServeWS handles websocket requests from the peer. This runs in its own goroutine.

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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

type ConnMessage

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

A ConnMessage is a message that just gets sent to a single socket connection.

type Hub

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

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

func NewHub

func NewHub(cfg *config.Config) (*Hub, error)

func (*Hub) PubsubProcess

func (h *Hub) PubsubProcess()

PubsubProcess processes pubsub messages.

func (*Hub) Run

func (h *Hub) Run()

type PubSub

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

PubSub encapsulates the various subscriptions to the different channels. The `liwords` package should have a very similar structure.

type Realm

type Realm string

A Realm is basically a set of clients. It can be thought of as a game room, or perhaps a lobby.

const LobbyRealm Realm = "lobby"
const NullRealm Realm = ""

type RealmMessage

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

A RealmMessage is a message that should be sent to a socket Realm.

type UserMessage

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

A UserMessage is a message that should be sent to a user (across all of the sockets that they are connected to, unless the channel says otherwise).

Jump to

Keyboard shortcuts

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