aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/gateway/shard.rs2
-rw-r--r--src/ext/voice/connection.rs3
-rw-r--r--src/ext/voice/connection_info.rs3
-rw-r--r--src/ext/voice/handler.rs9
-rw-r--r--src/ext/voice/manager.rs6
-rw-r--r--src/ext/voice/payload.rs4
6 files changed, 19 insertions, 8 deletions
diff --git a/src/client/gateway/shard.rs b/src/client/gateway/shard.rs
index c026f0c..bc2b813 100644
--- a/src/client/gateway/shard.rs
+++ b/src/client/gateway/shard.rs
@@ -149,7 +149,7 @@ impl Shard {
session_id: Some(ready.ready.session_id.clone()),
shard_info: shard_info,
ws_url: base_url.to_owned(),
- manager: VoiceManager::new(tx, ready.ready.user.id.0),
+ manager: VoiceManager::new(tx, ready.ready.user.id),
}
} else {
Shard {
diff --git a/src/ext/voice/connection.rs b/src/ext/voice/connection.rs
index 373f4ef..3f40d85 100644
--- a/src/ext/voice/connection.rs
+++ b/src/ext/voice/connection.rs
@@ -27,6 +27,7 @@ use ::internal::prelude::*;
use ::internal::ws_impl::{ReceiverExt, SenderExt};
use ::internal::Timer;
use ::model::event::VoiceEvent;
+use ::model::UserId;
enum ReceiverStatus {
Udp(Vec<u8>),
@@ -59,6 +60,7 @@ pub struct Connection {
thread_items: ThreadItems,
timestamp: u32,
udp: UdpSocket,
+ user_id: UserId,
}
impl Connection {
@@ -159,6 +161,7 @@ impl Connection {
ssrc: hello.ssrc,
thread_items: thread_items,
timestamp: 0,
+ user_id: info.user_id,
})
}
diff --git a/src/ext/voice/connection_info.rs b/src/ext/voice/connection_info.rs
index c257e4a..282b5f1 100644
--- a/src/ext/voice/connection_info.rs
+++ b/src/ext/voice/connection_info.rs
@@ -1,7 +1,10 @@
+use ::model::UserId;
+
#[derive(Clone, Debug)]
pub struct ConnectionInfo {
pub endpoint: String,
pub session_id: String,
pub target_id: u64,
pub token: String,
+ pub user_id: UserId,
}
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,
}))
}
diff --git a/src/ext/voice/manager.rs b/src/ext/voice/manager.rs
index b4f3501..4e71195 100644
--- a/src/ext/voice/manager.rs
+++ b/src/ext/voice/manager.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::sync::mpsc::Sender as MpscSender;
use super::{Handler, Target};
use ::client::gateway::GatewayStatus;
-use ::model::{ChannelId, GuildId};
+use ::model::{ChannelId, GuildId, UserId};
/// A manager is a struct responsible for managing [`Handler`]s which belong to
/// a single [WebSocket connection]. This is a fairly complex key-value store,
@@ -22,13 +22,13 @@ use ::model::{ChannelId, GuildId};
/// [WebSocket connection]: ../../client/struct.Connection.html
pub struct Manager {
handlers: HashMap<Target, Handler>,
- user_id: u64,
+ user_id: UserId,
ws: MpscSender<GatewayStatus>,
}
impl Manager {
#[doc(hidden)]
- pub fn new(ws: MpscSender<GatewayStatus>, user_id: u64) -> Manager {
+ pub fn new(ws: MpscSender<GatewayStatus>, user_id: UserId) -> Manager {
Manager {
handlers: HashMap::new(),
user_id: user_id,
diff --git a/src/ext/voice/payload.rs b/src/ext/voice/payload.rs
index c9ceeeb..45ccf4d 100644
--- a/src/ext/voice/payload.rs
+++ b/src/ext/voice/payload.rs
@@ -2,6 +2,8 @@ use serde_json::builder::ObjectBuilder;
use serde_json::Value;
use super::connection_info::ConnectionInfo;
use ::constants::VoiceOpCode;
+
+#[cfg(feature="cache")]
use ::client::CACHE;
#[inline]
@@ -12,7 +14,7 @@ pub fn build_identify(info: &ConnectionInfo) -> Value {
.insert("server_id", info.target_id)
.insert("session_id", &info.session_id)
.insert("token", &info.token)
- .insert("user_id", CACHE.read().unwrap().user.id.0))
+ .insert("user_id", info.user_id.0))
.build()
}