pub struct OrdrWebsocket { /* private fields */ }Expand description
Connection to the o!rdr websocket.
Await events with OrdrWebsocket::next_event.
To gracefully shut the connection down, use OrdrWebsocket::disconnect.
Verified bots that should also receive events about their private and
unlisted renders must call OrdrWebsocket::authenticate after
connecting.
Implementations§
Source§impl OrdrWebsocket
impl OrdrWebsocket
Sourcepub async fn connect() -> Result<Self, WebsocketError>
pub async fn connect() -> Result<Self, WebsocketError>
Connect to the o!rdr websocket.
Sourcepub async fn next_event(&mut self) -> Result<RawEvent, WebsocketError>
pub async fn next_event(&mut self) -> Result<RawEvent, WebsocketError>
Await the next o!rdr websocket event.
This can block indefinitely when the connection is alive but no events arrive, so apply an idle timeout around it if that should count as a dead connection.
Sourcepub async fn authenticate(&mut self, key: &str) -> Result<(), WebsocketError>
pub async fn authenticate(&mut self, key: &str) -> Result<(), WebsocketError>
Authenticate this connection as a verified bot.
Emits the bot_auth event with the bot’s API key and waits for the
server’s reply on the same event. Once authenticated, events about the
bot’s private and unlisted renders are included in the stream.
Like OrdrWebsocket::next_event, this can block indefinitely while
the connection is alive. Events that arrive before the authentication
reply are dropped.
Sourcepub async fn disconnect(self) -> Result<(), WebsocketError>
pub async fn disconnect(self) -> Result<(), WebsocketError>
Gracefully disconnect from the websocket.