Skip to main content

VoiceSession

Struct VoiceSession 

Source
pub struct VoiceSession { /* private fields */ }
Expand description

One stay in a voice channel. Dropping it leaves the channel.

Implementations§

Source§

impl VoiceSession

Source

pub const fn community(&self) -> CommunityId

The community.

Source

pub const fn channel(&self) -> ChannelId

The voice channel.

Source

pub const fn voice_session(&self) -> VoiceSessionId

This stay’s voice session, as the host named it.

Source

pub fn send_audio(&self, frame: &[u8])

Sends one Opus packet to every connected participant, sealed, now: the caller keeps the time (one packet per 20 ms for 20 ms packets). Its duration comes from its TOC byte. Frames are dropped while this member is muted (by itself or a moderator) or may not speak. To play files or streams in real time, subscribe to an AudioPlayer instead.

Source

pub fn subscribe(&self, player: &AudioPlayer)

Sends what player plays (discord.js’s connection.subscribe(player)), instead of any player subscribed before. The player does not keep this session alive.

Source

pub fn unsubscribe(&self, player: &AudioPlayer)

Stops sending what player plays.

Source

pub fn frames_refused(&self) -> u64

How many frames arrived from participants and did not open (a wrong key, a damaged frame, one that was never sealed, or one sealed under an epoch this stay never had or no longer keeps, around joins and leaves); none are played.

Source

pub fn can_send(&self) -> bool

Whether frames given to send_audio are sent now.

Source

pub fn next_event(&self, timeout: Duration) -> Option<VoiceEvent>

The next event, or None when none arrives within timeout or the session ended.

Source

pub fn events(&self) -> impl Iterator<Item = VoiceEvent> + Send + 'static

The events, blocking; ends with the session.

Source

pub fn set_self(&self, mute: Option<bool>, deaf: Option<bool>) -> Result<()>

Mutes or deafens this member (voice.update); deafened, incoming audio is dropped.

§Errors

The host refused or did not answer.

Source

pub fn leave(self) -> Result<()>

Leaves the channel (voice.leave) and closes every media connection.

§Errors

The host refused or did not answer; the media is closed either way.

Trait Implementations§

Source§

impl Drop for VoiceSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more