OxL Reference

data WsMessage

A message received on a WebSocket. For Text the field text is set, for Binary/Ping/Pong the field data; for Close the fields code and reason.

Example:

oxl✓ checked in CI
use std.http { WsMessage, WsKind }

fn main() io {
  let m = WsMessage{ kind: WsKind.Text, text: "hello" }
  print("{m.text} {m.code}")
}
Output
hello 0
pub(api) data WsMessage

Since. 1.0.0-beta

Fields

pub(api) kind: WsKind

Kind of the message.

pub(api) text: str = ""

The text of a Text message.

pub(api) payload: bytes = Utf8.encode("")

The data of a Binary, Ping or Pong message.

pub(api) code: i64 = 0

The close code of a Close message.

pub(api) reason: str = ""

The close reason of a Close message.

Defined in: std/http/http.oxl:2101

See also