lustre_websocket
Types
pub type WebSocketCloseReason {
Normal
GoingAway
ProtocolError
UnexpectedTypeOfData
NoCodeFromServer
AbnormalClose
IncomprehensibleFrame
PolicyViolated
MessageTooBig
FailedExtensionNegotation
UnexpectedFailure
FailedTLSHandshake
OtherCloseReason
}
Constructors
-
Normal
-
GoingAway
-
ProtocolError
-
UnexpectedTypeOfData
-
NoCodeFromServer
-
AbnormalClose
-
IncomprehensibleFrame
-
PolicyViolated
-
MessageTooBig
-
FailedExtensionNegotation
-
UnexpectedFailure
-
FailedTLSHandshake
-
OtherCloseReason
pub type WebSocketEvent {
InvalidUrl
OnOpen(WebSocket)
OnTextMessage(String)
OnBinaryMessage(BitArray)
OnClose(WebSocketCloseReason)
}
Constructors
-
InvalidUrl
-
OnOpen(WebSocket)
-
OnTextMessage(String)
-
OnBinaryMessage(BitArray)
-
OnClose(WebSocketCloseReason)
Functions
pub fn do_get_page_url() -> String
pub fn do_get_websocket_path(
path: String,
page_uri: Uri,
) -> Result(String, Nil)
pub fn get_websocket_path(path: String) -> Result(String, Nil)
pub fn init(
path: String,
wrapper: fn(WebSocketEvent) -> a,
) -> Effect(a)
Initialize a websocket. These constructs are fully asynchronous, so you must provide a wrapper
that takes a WebSocketEvent
and turns it into a lustre message of your application.
If the path given is a URL, that is used.
If the path is an absolute path, host and port are taken from
document.URL, and scheme will become ws for http and wss for https.
If the path is a relative path, ditto, but the the path will be
relative to the path from document.URL