aboutsummaryrefslogtreecommitdiff
path: root/src/gateway/mod.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-01-18 08:33:27 -0800
committerZeyla Hellyer <[email protected]>2018-01-18 08:33:27 -0800
commit9232b8f065deb4637a74e7f85ab617bb527c51be (patch)
tree9c2cc2bd6b6238a1bd039e9ad4900e8705197af2 /src/gateway/mod.rs
parentFix travis' cache by chmoding $HOME/.cargo (#252) (diff)
downloadserenity-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/gateway/mod.rs')
-rw-r--r--src/gateway/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gateway/mod.rs b/src/gateway/mod.rs
index 8445b29..c4748a0 100644
--- a/src/gateway/mod.rs
+++ b/src/gateway/mod.rs
@@ -59,10 +59,14 @@ pub use self::ws_client_ext::WebSocketGatewayClientExt;
use model::gateway::Game;
use model::user::OnlineStatus;
+use serde_json::Value;
use std::fmt::{Display, Formatter, Result as FmtResult};
use websocket::sync::client::Client;
use websocket::sync::stream::{TcpStream, TlsStream};
+#[cfg(feature = "client")]
+use client::bridge::gateway::ShardClientMessage;
+
pub type CurrentPresence = (Option<Game>, OnlineStatus);
pub type WsClient = Client<TlsStream<TcpStream>>;
@@ -163,6 +167,18 @@ impl Display for ConnectionStage {
}
}
+/// A message to be passed around within the library.
+///
+/// As a user you usually don't need to worry about this, but when working with
+/// the lower-level internals of the `client`, `gateway, and `voice` modules it
+/// may be necessary.
+#[derive(Clone, Debug)]
+pub enum InterMessage {
+ #[cfg(feature = "client")]
+ Client(ShardClientMessage),
+ Json(Value),
+}
+
pub enum ShardAction {
Heartbeat,
Identify,