gossamer/web_socket
Types
Values
pub fn binary_type(
of socket: WebSocket,
) -> binary_type.BinaryType
pub fn buffered_amount(of socket: WebSocket) -> Int
Returns the number of bytes of application data (UTF-8 text and binary
data) that have been queued using send but not yet been transmitted to
the network.
If the WebSocket connection is closed, this attribute’s value will only
increase with each call to the send method. (The number does not reset
to zero once the connection closes.)
pub fn close_with(
socket: WebSocket,
code code: Int,
reason reason: String,
) -> Nil
pub fn extensions(of socket: WebSocket) -> String
pub fn new(url: String) -> Result(WebSocket, String)
Creates a new WebSocket connection to the given URL.
Examples
let assert Ok(ws) = web_socket.new("ws://localhost:8080")
pub fn new_with_protocols(
url: String,
with protocols: List(String),
) -> Result(WebSocket, String)
Creates a new WebSocket connection to the given URL with the
specified sub-protocols.
Examples
let assert Ok(ws) = web_socket.new_with_protocols("ws://localhost:8080", ["json"])
pub fn on_close(
socket: WebSocket,
run handler: fn(close_event.CloseEvent) -> a,
) -> Nil
pub fn on_message(
socket: WebSocket,
run handler: fn(message_event.MessageEvent) -> a,
) -> Nil
pub fn ready_state(
of socket: WebSocket,
) -> ready_state.ReadyState
pub fn send_dynamic(to socket: WebSocket, data data: a) -> Nil
pub fn set_binary_type(
of socket: WebSocket,
to value: binary_type.BinaryType,
) -> Nil