Skip to content

Struct VoiceSession

zaun_client::VoiceSession · Struct

pub struct VoiceSession { … }

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

pub const fn community(&self) -> CommunityId

The community.

pub const fn channel(&self) -> ChannelId

The voice channel.

pub const fn voice_session(&self) -> VoiceSessionId

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

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.

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.

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

Stops sending what player plays.

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.

pub fn can_send(&self) -> bool

Whether frames given to send_audio are sent now.

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

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

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

The events, blocking; ends with the session.

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

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

The host refused or did not answer.

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

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

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

Drop

Full rustdoc page