mist/websocket

Types

pub type Frame {
  CloseFrame(payload_length: Int, payload: BitString)
  TextFrame(payload_length: Int, payload: BitString)
  BinaryFrame(payload_length: Int, payload: BitString)
  PingFrame(payload_length: Int, payload: BitString)
  PongFrame(payload_length: Int, payload: BitString)
}

Constructors

  • CloseFrame(payload_length: Int, payload: BitString)
  • TextFrame(payload_length: Int, payload: BitString)
  • BinaryFrame(payload_length: Int, payload: BitString)
  • PingFrame(payload_length: Int, payload: BitString)
  • PongFrame(payload_length: Int, payload: BitString)
pub type Handler =
  fn(Message, Subject(HandlerMessage)) -> Result(Nil, Nil)
pub type Message {
  BinaryMessage(data: BitString)
  TextMessage(data: String)
}

Constructors

  • BinaryMessage(data: BitString)
  • TextMessage(data: String)
pub type ShaHash {
  Sha
}

Constructors

  • Sha
pub type WebsocketHandler {
  WebsocketHandler(
    on_close: Option(fn(Subject(HandlerMessage)) -> Nil),
    on_init: Option(fn(Subject(HandlerMessage)) -> Nil),
    handler: Handler,
  )
}

Constructors

  • WebsocketHandler(
      on_close: Option(fn(Subject(HandlerMessage)) -> Nil),
      on_init: Option(fn(Subject(HandlerMessage)) -> Nil),
      handler: Handler,
    )

Functions

pub external fn base64_encode(data: String) -> String
pub external fn crypto_hash(
  hash: ShaHash,
  data: String,
) -> String
pub fn echo_handler(message: Message, sender: Subject(
    HandlerMessage,
  )) -> Result(Nil, Nil)
pub fn frame_from_message(socket: Socket, transport: Transport, message: BitString) -> Result(
  Frame,
  Nil,
)
pub fn frame_to_bit_builder(frame: Frame) -> BitBuilder
pub fn on_close(handler: WebsocketHandler, func: fn(
    Subject(HandlerMessage),
  ) -> Nil) -> WebsocketHandler
pub fn on_init(handler: WebsocketHandler, func: fn(
    Subject(HandlerMessage),
  ) -> Nil) -> WebsocketHandler
pub fn parse_key(key: String) -> String
pub fn send(sender: Subject(HandlerMessage), message: Message) -> Nil

Helper to encapsulate the logic to send a provided message over the WebSocket

pub fn with_handler(func: fn(Message, Subject(HandlerMessage)) ->
    Result(Nil, Nil)) -> WebsocketHandler
Search Document