Driver: Automate (re)connection logic (#81)
This PR adds several enhancements to Driver connection logic: * Driver (re)connection attempts now have a default timeout of around 10s. * The driver will now attempt to retry full connection attempts using a user-provided strategy: currently, this defaults to 5 attempts under an exponential backoff strategy. * The driver will now fire `DriverDisconnect` events at the end of any session -- this unifies (re)connection failure events with session expiry as seen in #76, which should provide users with enough detail to know *which* voice channel to reconnect to. Users still need to be careful to read the session/channel IDs to ensure that they aren't overwriting another join. This has been tested using `cargo make ready`, and by setting low timeouts to force failures in the voice receive example (with some additional error handlers). Closes #68.
This commit is contained in:
@@ -33,12 +33,22 @@ pub enum CoreEvent {
|
||||
DriverConnect,
|
||||
/// Fires when this driver successfully reconnects after a network error.
|
||||
DriverReconnect,
|
||||
#[deprecated(
|
||||
since = "0.2.0",
|
||||
note = "Please use the DriverDisconnect event instead."
|
||||
)]
|
||||
/// Fires when this driver fails to connect to a voice channel.
|
||||
DriverConnectFailed,
|
||||
#[deprecated(
|
||||
since = "0.2.0",
|
||||
note = "Please use the DriverDisconnect event instead."
|
||||
)]
|
||||
/// 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,
|
||||
/// Fires when this driver fails to connect to, or drops from, a voice channel.
|
||||
DriverDisconnect,
|
||||
/// Fires whenever the driver is assigned a new [RTP SSRC] by the voice server.
|
||||
///
|
||||
/// This typically fires alongside a [DriverConnect], or a full [DriverReconnect].
|
||||
|
||||
Reference in New Issue
Block a user