wswire

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtrlAuth       = "auth"
	CtrlSubscribe  = "subscribe"
	CtrlUnsub      = "unsubscribe"
	ConfirmPrefix  = "confirmed:"
	RejectedPrefix = "rejected:"
)
View Source
const (
	ScopeWorkspace = "workspace"
	ScopeUser      = "user"
)
View Source
const (
	CapBatch        = "batch"
	CapNotification = "notification"
	CapWorkspace    = "workspace"
)
View Source
const ConnectedFrameType = "connected"

Variables

This section is empty.

Functions

func Capabilities

func Capabilities() []string

func IsRegisteredScope

func IsRegisteredScope(name string) bool

func RegisterCapability

func RegisterCapability(name string) error

func RegisterScope

func RegisterScope(name string) error

func ScopeKey

func ScopeKey(prefix, id string) string

func WSName

func WSName(dotEvent string) string

Types

type ControlFrame added in v0.4.1

type ControlFrame struct {
	Type    string          `json:"type"`
	Token   string          `json:"token"`
	Scope   string          `json:"scope"`
	ID      string          `json:"id"`
	Payload json.RawMessage `json:"payload"`
}

ControlFrame is the canonical decode target for inbound control frames (auth / subscribe / unsubscribe). Control fields are accepted from EITHER shape (F16): the flat form `{"type":"subscribe","scope":"task","id":"1"}` and the nested form `{"type":"subscribe","payload":{"scope":"task","id":"1"}}` — the JS WsClient's send() encodes the nested one. Top-level fields win when both are present.

func DecodeControl added in v0.4.1

func DecodeControl(raw []byte) (ControlFrame, bool)

DecodeControl parses a control frame and normalizes the nested payload into the flat fields: if Scope/ID/Token are empty at the top level, they are read out of payload when it is a JSON object.

type Frame

type Frame struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload,omitempty"`
	EventID string          `json:"event_id,omitempty"`
}

Jump to

Keyboard shortcuts

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