wsx

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultPATPrefix is the fallback PAT token prefix for Hub.PATPrefix when
	// empty. It aliases webx.DefaultPATPrefix — the canonical constant of the
	// PAT chain (identity/domain mints, webx parses, wsx authenticates the
	// first WS frame); the internal/arch parity test pins them together.
	DefaultPATPrefix = webx.DefaultPATPrefix
)

Variables

This section is empty.

Functions

func Capabilities

func Capabilities() []string

func RegisterCapability

func RegisterCapability(name string) error

func RegisterScope

func RegisterScope(name string) error

func UserScope

func UserScope(userID string) string

func WorkspaceScope

func WorkspaceScope(workspaceID string) string

Types

type Authorize

type Authorize func(ctx context.Context, p *webx.Principal, connWorkspace, scopePrefix, id string) bool

type Broadcaster

type Broadcaster interface {
	Broadcast(ctx context.Context, scope string, frame wswire.Frame)
	SendToUser(ctx context.Context, userID string, frame wswire.Frame)
}

type Hub

type Hub struct {
	Log *slog.Logger

	Metrics Metrics

	Authorize Authorize

	WorkspaceMember WorkspaceMember

	PATResolve PATResolve

	PATPrefix string

	OnSubscribe   func(scope string)
	OnUnsubscribe func(scope string)

	AllowedOrigins []string

	Capabilities []string

	Relay interface {
		PublishOut(ctx context.Context, scope string, frame wswire.Frame)
	}
	// contains filtered or unexported fields
}

func NewHub

func NewHub(log *slog.Logger) *Hub

func (*Hub) Broadcast

func (h *Hub) Broadcast(ctx context.Context, scope string, frame wswire.Frame)

func (*Hub) BroadcastEvent

func (h *Hub) BroadcastEvent(ctx context.Context, scope, event string, payload []byte, eventID string) error

func (*Hub) DeliverRemote

func (h *Hub) DeliverRemote(scope string, frame wswire.Frame)

func (*Hub) RoomSize

func (h *Hub) RoomSize(scope string) int

func (*Hub) Rooms

func (h *Hub) Rooms() int

func (*Hub) SendToUser

func (h *Hub) SendToUser(ctx context.Context, userID string, frame wswire.Frame)

func (*Hub) ServeWS

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

type Metrics

type Metrics interface {
	Incr(name string)
	Gauge(name string, v float64)
}

type PATResolve

type PATResolve func(ctx context.Context, token string) (*webx.Principal, error)

type WorkspaceMember

type WorkspaceMember func(ctx context.Context, p *webx.Principal, workspaceID string) bool

func MemberGate

func MemberGate(lookup func(ctx context.Context, workspaceID, userID string) (bool, error)) WorkspaceMember

Jump to

Keyboard shortcuts

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