Events: Add (re)connect success/fail events.

These should allow bots to hook up events to a variety of important connection events as required. This was primarily motivated by the user who raised dcb6ad9.

Although I really would have liked to squeeze in (finite) reconnection attempts with exponential backoff, so that automated repeat attempts could be neatly handled, `Config` was accidentally *not* made non-exhaustive. Adding this and its needed configuration would then be a breaking change. This should warn users about an accidentally dead connection, until the next version can be put forth.
This commit is contained in:
Kyle Simpson
2021-01-17 22:22:23 +00:00
parent 55b8e7fb4e
commit cb2398f182
3 changed files with 60 additions and 0 deletions

View File

@@ -29,4 +29,14 @@ pub enum CoreEvent {
ClientConnect,
/// Fires whenever a user disconnects from the same stream as the bot.
ClientDisconnect,
/// Fires when this driver successully connects to a voice channel.
DriverConnect,
/// Fires when this driver successful reconnects after a network error.
DriverReconnect,
/// Fires when this driver fails to connect to a voice channel.
DriverConnectFailed,
/// Fires when this driver fails to reconnect to a voice channel after a network error.
///
/// Users will need to manually reconnect on receipt of this error.
DriverReconnectFailed,
}