diff options
| author | Zeyla Hellyer <[email protected]> | 2018-01-18 08:33:27 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2018-01-18 08:33:27 -0800 |
| commit | 9232b8f065deb4637a74e7f85ab617bb527c51be (patch) | |
| tree | 9c2cc2bd6b6238a1bd039e9ad4900e8705197af2 /src/voice/handler.rs | |
| parent | Fix travis' cache by chmoding $HOME/.cargo (#252) (diff) | |
| download | serenity-9232b8f065deb4637a74e7f85ab617bb527c51be.tar.xz serenity-9232b8f065deb4637a74e7f85ab617bb527c51be.zip | |
Use an InterMessage to communicate over gateway
Instead of communicating over the gateway in a split form of a
`serde_json::Value` or a `client::bridge::gateway::ShardClientMessage`,
wrap them both into a single enum for better interaction between the
client, gateway, and voice modules.
Diffstat (limited to 'src/voice/handler.rs')
| -rw-r--r-- | src/voice/handler.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/voice/handler.rs b/src/voice/handler.rs index 94f7c07..d4085d5 100644 --- a/src/voice/handler.rs +++ b/src/voice/handler.rs @@ -1,7 +1,7 @@ use constants::VoiceOpCode; +use gateway::InterMessage; use model::id::{ChannelId, GuildId, UserId}; use model::voice::VoiceState; -use serde_json::Value; use std::sync::mpsc::{self, Sender as MpscSender}; use super::connection_info::ConnectionInfo; use super::{AudioReceiver, AudioSource, Status as VoiceStatus, threading}; @@ -98,13 +98,17 @@ pub struct Handler { /// /// When set via [`standalone`][`Handler::standalone`], it will not be /// present. - ws: Option<MpscSender<Value>>, + ws: Option<MpscSender<InterMessage>>, } impl Handler { /// Creates a new Handler. #[inline] - pub(crate) fn new(guild_id: GuildId, ws: MpscSender<Value>, user_id: UserId) -> Self { + pub(crate) fn new( + guild_id: GuildId, + ws: MpscSender<InterMessage>, + user_id: UserId, + ) -> Self { Self::new_raw(guild_id, Some(ws), user_id) } @@ -346,7 +350,11 @@ impl Handler { } } - fn new_raw(guild_id: GuildId, ws: Option<MpscSender<Value>>, user_id: UserId) -> Self { + fn new_raw( + guild_id: GuildId, + ws: Option<MpscSender<InterMessage>>, + user_id: UserId, + ) -> Self { let (tx, rx) = mpsc::channel(); threading::start(guild_id, rx); @@ -407,7 +415,7 @@ impl Handler { } }); - let _ = ws.send(map); + let _ = ws.send(InterMessage::Json(map)); } } } |