diff options
| author | Austin Hellyer <[email protected]> | 2016-12-16 21:26:54 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-12-16 21:26:54 -0800 |
| commit | 7b45f16f063a47dc8a302dce5b016cf43a3edcc1 (patch) | |
| tree | 42586d38945cdbe1583dee4ea59d47060e86e61f /src/ext/voice/handler.rs | |
| parent | Simplify gateway identify compression (diff) | |
| download | serenity-7b45f16f063a47dc8a302dce5b016cf43a3edcc1.tar.xz serenity-7b45f16f063a47dc8a302dce5b016cf43a3edcc1.zip | |
Make 'voice' feature not require 'cache'
The voice module required the cache feature in order to access the
current user's Id. Instead, just copy the Id into the VoiceManager and
distribute it from there -- the memory impact will be very minimal in
comparison to the benefits of not needing to constantly unlock the Cache
and not needing the user to be forced to use the Cache.
Diffstat (limited to 'src/ext/voice/handler.rs')
| -rw-r--r-- | src/ext/voice/handler.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ext/voice/handler.rs b/src/ext/voice/handler.rs index 16f700a..e9e5cd6 100644 --- a/src/ext/voice/handler.rs +++ b/src/ext/voice/handler.rs @@ -5,7 +5,7 @@ use super::connection_info::ConnectionInfo; use super::{Status as VoiceStatus, Target}; use ::client::gateway::GatewayStatus; use ::constants::VoiceOpCode; -use ::model::{ChannelId, GuildId, VoiceState}; +use ::model::{ChannelId, GuildId, UserId, VoiceState}; use super::threading; /// The handler is responsible for "handling" a single voice connection, acting @@ -39,7 +39,7 @@ pub struct Handler { self_mute: bool, sender: MpscSender<VoiceStatus>, session_id: Option<String>, - user_id: u64, + user_id: UserId, ws: MpscSender<GatewayStatus>, } @@ -53,7 +53,7 @@ impl Handler { /// /// [`Manager::join`]: struct.Manager.html#method.join #[doc(hidden)] - pub fn new(target: Target, ws: MpscSender<GatewayStatus>, user_id: u64) + pub fn new(target: Target, ws: MpscSender<GatewayStatus>, user_id: UserId) -> Self { let (tx, rx) = mpsc::channel(); @@ -266,11 +266,14 @@ impl Handler { return; }; + let user_id = self.user_id; + self.send(VoiceStatus::Connect(ConnectionInfo { endpoint: endpoint, session_id: session_id, target_id: target_id, token: token, + user_id: user_id, })) } |