Gateway: Add connection timeout, add Config to gateway. (#51)
This change fixes tasks hanging due to rare cases of messages being lost between full Discord reconnections by placing a configurable timeout on the `ConnectionInfo` responses. This is a companion fix to [serenity#1255](https://github.com/serenity-rs/serenity/pull/1255). To make this doable, `Config`s are now used by all versions of `Songbird`/`Call`, and relevant functions are added to simplify setup with configuration. These are now non-exhaustive, correcting an earlier oversight. For future extensibility, this PR moves the return type of `join`/`join_gateway` into a custom future (no longer leaking flume's `RecvFut` type). Additionally, this fixes the Makefile's feature sets for driver/gateway-only compilation. This is a breaking change in: * the return types of `join`/`join_gateway` * moving `crate::driver::Config` -> `crate::Config`, * `Config` and `JoinError` becoming `#[non_breaking]`. This was tested via `cargo make ready`, and by testing `examples/serenity/voice_receive` with various timeout settings.
This commit is contained in:
@@ -17,6 +17,7 @@ pub enum Recipient {
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
pub enum Error {
|
||||
Crypto(CryptoError),
|
||||
/// Received an illegal voice packet on the voice UDP socket.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use super::{disposal, error::Result, message::*, Config};
|
||||
use super::{disposal, error::Result, message::*};
|
||||
use crate::{
|
||||
constants::*,
|
||||
tracks::{PlayMode, Track},
|
||||
Config,
|
||||
};
|
||||
use audiopus::{
|
||||
coder::Encoder as OpusEncoder,
|
||||
|
||||
@@ -9,11 +9,8 @@ pub(crate) mod udp_rx;
|
||||
pub(crate) mod udp_tx;
|
||||
pub(crate) mod ws;
|
||||
|
||||
use super::{
|
||||
connection::{error::Error as ConnectionError, Connection},
|
||||
Config,
|
||||
};
|
||||
use crate::events::CoreContext;
|
||||
use super::connection::{error::Error as ConnectionError, Connection};
|
||||
use crate::{events::CoreContext, Config};
|
||||
use flume::{Receiver, RecvError, Sender};
|
||||
use message::*;
|
||||
#[cfg(not(feature = "tokio-02-marker"))]
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
use super::{
|
||||
error::{Error, Result},
|
||||
message::*,
|
||||
Config,
|
||||
};
|
||||
use crate::{
|
||||
constants::*,
|
||||
driver::{Config, DecodeMode},
|
||||
events::CoreContext,
|
||||
};
|
||||
use crate::{constants::*, driver::DecodeMode, events::CoreContext};
|
||||
use audiopus::{
|
||||
coder::Decoder as OpusDecoder,
|
||||
error::{Error as OpusError, ErrorCode},
|
||||
|
||||
Reference in New Issue
Block a user