Skip to content

Commit

Permalink
Gateway: Allow connection info to be retrieved (#49)
Browse files Browse the repository at this point in the history
This is a simple addition to allow current connection state to be retrieved *after* establishment, even when using the voice driver.

This has been tested using `cargo make ready`, as it is fairly simple functionality.
  • Loading branch information
FelixMcFelix authored Mar 22, 2021
1 parent a3f86ad commit db79940
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ impl Call {
self.update().await.map(|_| rx.into_recv_async())
}

/// Returns the current voice connection details for this Call,
/// if available.
#[instrument(skip(self))]
pub fn current_connection(&self) -> Option<&ConnectionInfo> {
match &self.connection {
Some((_, progress, _)) => progress.get_connection_info(),
_ => None,
}
}

/// Leaves the current voice channel, disconnecting from it.
///
/// This does _not_ forget settings, like whether to be self-deafened or
Expand Down
8 changes: 8 additions & 0 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ impl ConnectionProgress {
})
}

pub(crate) fn get_connection_info(&self) -> Option<&ConnectionInfo> {
use ConnectionProgress::*;
match self {
Complete(c) => Some(&c),
_ => None,
}
}

pub(crate) fn apply_state_update(&mut self, session_id: String) -> bool {
use ConnectionProgress::*;
match self {
Expand Down

0 comments on commit db79940

Please sign in to comment.