nerf/websocket

Types

The URI of the websocket server to connect to

pub type ConnectError {
  ConnectionRefused(status: Int, headers: List(Header))
  ConnectionFailed(reason: Dynamic)
}

Constructors

  • ConnectionRefused(status: Int, headers: List(Header))
  • ConnectionFailed(reason: Dynamic)
pub opaque type Connection
pub type Frame {
  Close
  Text(String)
  Binary(BitString)
}

Constructors

  • Close
  • Text(String)
  • Binary(BitString)

Functions

pub fn close(conn: Connection) -> Nil
pub fn connect(hostname: String, path: String, on port: Int, with headers: List(
    #(String, String),
  )) -> Result(Connection, ConnectError)
pub external fn receive(
  from: Connection,
  within: Int,
) -> Result(Frame, Nil)
pub fn send(to conn: Connection, this message: String) -> Nil
pub fn send_binary(to conn: Connection, this message: BitString) -> Nil
pub fn send_binary_builder(to conn: Connection, this message: BitBuilder) -> Nil
pub fn send_builder(to conn: Connection, this message: StringBuilder) -> Nil
Search Document