lustre_websocket
Types
pub external type WebSocket
pub type WebSocketCloseReason {
Normal
GoingAway
ProtocolError
UnexpectedTypeOfData
NoCodeFromServer
AbnormalClose
IncomprehensibleFrame
PolicyViolated
MessageTooBig
FailedExtensionNegotation
UnexpectedFailure
FailedTLSHandshake
}
Constructors
-
Normal -
GoingAway -
ProtocolError -
UnexpectedTypeOfData -
NoCodeFromServer -
AbnormalClose -
IncomprehensibleFrame -
PolicyViolated -
MessageTooBig -
FailedExtensionNegotation -
UnexpectedFailure -
FailedTLSHandshake
pub type WebSocketEvent {
OnOpen(WebSocket)
OnMessage(String)
OnClose(WebSocketCloseReason)
}
Constructors
-
OnOpen(WebSocket) -
OnMessage(String) -
OnClose(WebSocketCloseReason)
Functions
pub fn init(path: String, wrapper: fn(WebSocketEvent) -> a) -> Cmd(
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.
pub fn send(ws: WebSocket, msg: String) -> Cmd(a)
Send a text message over the web socket. This is asynchronous. There is no
expectation of a reply. See init. Only works on an Non-Closed socket.
Returns a Cmd(a) that you must pass as second entry in the lustre update return.