Enum web_socket::Event
source · pub enum Event {
Data {
ty: DataType,
data: Box<[u8]>,
},
Ping(Box<[u8]>),
Pong(Box<[u8]>),
Error(&'static str),
Close {
code: u16,
reason: Box<str>,
},
}
Expand description
Represent a websocket event
Variants§
Data
Fields
Websocket data frame.
Ping(Box<[u8]>)
A Ping frame may serve either as a keepalive or as a means to verify that the remote endpoint is still responsive.
And SHOULD respond with Pong frame as soon as is practical.
Pong(Box<[u8]>)
A Pong frame sent in response to a Ping frame must have identical “Application data” as found in the message body of the Ping frame being replied to.
If an endpoint receives a Ping frame and has not yet sent Pong frame(s) in response to previous Ping frame(s), the endpoint MAY elect to send a Pong frame for only the most recently processed Ping frame.
A Pong frame MAY be sent unsolicited. This serves as a unidirectional heartbeat. A response to an unsolicited Pong frame is not expected.
Error(&'static str)
represents the websocket error message.
Close
Fields
represents a successful close event of the WebSocket connection.