Skip to main content

Module websocket

Module websocket 

Source
Expand description

The WebSocket Event I/O Processor: the frames both ends speak and the delivery state of one peer link, shared by the browser shell (vertep-wasm) and the server endpoint ([server], feature websocket).

Frames are JSON text messages tagged by type:

  • hello (client to server, first frame): the client’s node IRI, the credential its provider supplied, and the IRI prefixes of the actors it hosts.
  • welcome or refused (server to client): the connection is accepted, or its credential is refused (the server then closes it).
  • message: a Vertep envelope: message id, target IRI, origin IRI, event name, payload, send id and correlation id.
  • ack: the receiver accepted the message with that id into a mailbox.

Delivery is at least once. A Link keeps every message it sent until the peer acknowledges it and sends all of them again after a reconnect; receivers deduplicate by message id (the runtime journals message ids and drops a duplicate, see [[openspec:event-journal#Message Deduplication]]).

The runtime’s transactional outbox holds a send until delivery succeeds: a send offered to a LinkMailbox is refused with “awaiting acknowledgement” until the peer’s ack arrives, so the outbox retries it and its durable outbox mark passes it only once it is acknowledged. That makes the redelivery survive a crash of the sender, too.

Structs§

ClientResolver
Resolves the addresses a client sends to over its one Link to the server: every address (of the schemes it is registered for) that starts with one of targets, or every address when targets is empty. Addresses hosted locally never reach a resolver.
Link
The delivery state of one peer: the unacknowledged messages, the current connection, and the acknowledgements received. It outlives connections, so a reconnect sends every pending message again. It is Send + Sync; the I/O lives in the connection code, which hands the link a channel of outgoing frame texts on connect.
LinkMailbox
The runtime’s view of an actor reached through a Link: a mailbox that offers each message to the link. It accepts a message once the peer acknowledged it; until then it reports the delivery as failed, so the outbox keeps the send and retries it. A send refused by the peer’s credential check is recorded as a dead letter (reason transport-refused) and settled.
Message
A Vertep envelope on the wire.
WebSocketTransport
The WebSocket Event I/O Processor as a runtime transport (<send type="websocket"> or its type IRI). It delivers into the mailbox the address resolved to, which for a remote actor is a LinkMailbox; _ioprocessors lists it.

Enums§

Frame
One frame of the protocol.
Inbound
What the receiving side of a Link should do with a frame.
Offer
What became of a message offered to a Link.

Constants§

REFUSED_REASON
The dead-letter reason of a send whose connection credential was refused.
WEBSOCKET_PROCESSOR
The type IRI of the WebSocket Event I/O Processor (alias websocket). Events that arrive over WebSocket carry it as _event.origintype.