wire

package
v0.304.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PingLoop added in v0.300.2

func PingLoop(ctx context.Context, ccf context.CancelCauseFunc, doneCh <-chan struct{}, interval, timeout time.Duration, ws *websocket.Conn)

PingLoop sends periodic websocket pings and reports ping errors through ccf.

Returns immediately when interval is non-positive.

func ReadLoop

func ReadLoop(ctx context.Context, ccf context.CancelCauseFunc, doneCh <-chan struct{}, incomingMsgCh chan<- WsMsg, ws *websocket.Conn)

ReadLoop reads websocket text messages, parses them, and sends parsed messages on incomingMsgCh.

Closes incomingMsgCh on exit.

func WriteLoop

func WriteLoop(ctx context.Context, ccf context.CancelCauseFunc, doneCh <-chan struct{}, outboundMsgCh <-chan WsMsg, ws *websocket.Conn)

WriteLoop reads messages from outboundMsgCh, formats them, and writes them to the websocket.

Closes the websocket on exit.

Types

type Message

type Message struct {
	Dest any       // destination (tag, html ID or *Element)
	What what.What // what to change or do
	Data string    // data (e.g. inner HTML content or slice of tags)
}

Message contains the elements of a message to be sent to requests.

func (*Message) String

func (msg *Message) String() string

String returns the Message in a form suitable for debug output.

type WsMsg

type WsMsg struct {
	Data string    // data to send
	Jid  jid.Jid   // Jid to send, or -1 if Data contains that already
	What what.What // command
}

WsMsg is a message sent to or from a WebSocket.

func Parse

func Parse(txt []byte) (WsMsg, bool)

Parse parses an incoming text buffer into a message.

func (*WsMsg) Append

func (m *WsMsg) Append(b []byte) []byte

func (*WsMsg) FillAlert

func (m *WsMsg) FillAlert(err error)

func (*WsMsg) Format

func (m *WsMsg) Format() string

Jump to

Keyboard shortcuts

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