Skip to content
Strata is pre-1.0. APIs, protocol, and storage format may change.

strata_transport

strata_transport targets JavaScript. It wraps the browser WebSocket API. Use strata_client to encode and decode the text that it sends.

  • open_socket(url, on_open, on_message, on_close) -> Socket opens a browser WebSocket and registers callbacks.
  • send_text(socket, text) -> Result(Nil, SendError) sends text when the socket is open and returns Error(SocketNotOpen) when it is not.
  • close(socket) -> Nil starts a normal close.
  • websocket_url(host:, port:, path:, token:, secure:) -> String builds a Strata WebSocket URL and percent-encodes the token query value once.
  • random_replica_id() -> String makes a local CRDT replica id.

CloseEvent is a JavaScript dynamic value. The transport can call the close callback for both browser error and close events.

See Browser Transport for lifecycle and failure handling.

Source: packages/strata_transport.