ws

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 15 Imported by: 0

README

realtime-ws

Channel-based WebSocket transport for togo realtime (implements togo.Broker, overrides the default SSE broker when installed).

togo install togo-framework/realtime-ws

Channels & broadcasting

  • Clients subscribe over the socket: {"action":"subscribe","channel":"orders"}.
  • Public channels: any name. Private channels: prefix private- (require a ticket).
  • Broadcast to a channel by emitting "channel:event" (e.g. app.Emit(ctx, "orders:created", o)); a plain event (no :) goes to everyone.

Tickets (private channels)

GET /events/ticket returns a short-lived HMAC-signed ticket — mount it behind your auth so only authenticated users get one. The client connects with /events?ticket=...; a valid ticket unlocks private-* subscriptions. Set REALTIME_SECRET.

Documentation

Overview

Package ws is a channel-based WebSocket transport for togo realtime. It supports public and private channels, signed connection tickets (so private channels are authenticated), and channel-scoped broadcasting. It implements togo.Broker and overrides the default SSE broker when installed.

Publish uses an event of the form "channel:event" to target a channel (private channels are prefixed "private-"); an event with no ":" broadcasts to everyone.

Install: `togo install togo-framework/realtime-ws`. Env: REALTIME_SECRET.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBroker

func NewBroker() togo.Broker

NewBroker creates a channel-aware WebSocket broker.

Types

This section is empty.

Jump to

Keyboard shortcuts

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