strata_transport_gun
Erlang/Gun WebSocket transport for Strata.
CloseEvent
Section titled “CloseEvent”The reason that the receive process stopped.
pub type CloseEvent { Closed Failed(error.GluegunError)}Closed
Section titled “Closed”The peer sent a WebSocket close frame.
Failed(error.GluegunError)
Section titled “Failed(error.GluegunError)”Gluegun returned an error while it received a frame.
Options
Section titled “Options”Connection settings for open_socket.
pub type Options { Options(timeout: connection.Timeout, secure: Bool)}Socket
Section titled “Socket”A handle to a Gluegun WebSocket.
open_socket starts a process that receives frames from this socket.
pub type SocketFunctions
Section titled “Functions”Close the WebSocket.
Return a Gluegun error if the close operation fails.
pub fn close(Socket) -> Result(Nil, error.GluegunError)connection_path
Section titled “connection_path”Build the WebSocket connection path with an encoded token query parameter.
pub fn connection_path( String, String) -> Stringopen_socket
Section titled “open_socket”Open a WebSocket and start a receive process.
The function connects before it returns. It calls on_open after the
connection succeeds. It then starts a process that calls on_message for
each text frame. The process ignores other data frames. It calls on_close
when the peer closes the socket or when a receive operation fails.
The function returns a Gluegun error if the connection fails. It does not call a callback when the connection fails.
pub fn open_socket( host: String, port: Int, path: String, token: String, options: Options, on_open: fn(Socket) -> Nil, on_message: fn(String) -> Nil, on_close: fn(CloseEvent) -> Nil) -> Result(Socket, error.GluegunError)options
Section titled “options”Return the default connection settings.
The defaults use a five-second timeout and an insecure TCP connection.
pub fn options() -> Optionssend_text
Section titled “send_text”Send one text frame.
Return a Gluegun error if the send fails.
pub fn send_text( Socket, String) -> Result(Nil, error.GluegunError)with_secure
Section titled “with_secure”Select the connection transport.
Set secure to True to use TLS. Set it to False to use TCP.
pub fn with_secure( Options, Bool) -> Optionswith_timeout
Section titled “with_timeout”Set the connection timeout.
pub fn with_timeout( Options, connection.Timeout) -> Options