aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2017-01-21 08:37:07 -0800
committerAustin Hellyer <[email protected]>2017-01-21 08:37:07 -0800
commit4d5bb5c2c1082057d59d830a250ceeb985e5b83f (patch)
tree39098f2ce334dcbe385ebcf7b8f85b62f4206477 /src
parentReboot shard on broken pipe (diff)
downloadserenity-4d5bb5c2c1082057d59d830a250ceeb985e5b83f.tar.xz
serenity-4d5bb5c2c1082057d59d830a250ceeb985e5b83f.zip
Dispatch Ready events
Diffstat (limited to 'src')
-rw-r--r--src/client/mod.rs29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 3d712a5..eca4147 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -50,6 +50,7 @@ use ::internal::ws_impl::ReceiverExt;
use ::model::event::{
ChannelPinsAckEvent,
ChannelPinsUpdateEvent,
+ Event,
GatewayEvent,
GuildSyncEvent,
MessageUpdateEvent,
@@ -796,14 +797,23 @@ impl Client {
});
match boot {
- Ok((shard, _ready, receiver)) => {
+ Ok((shard, ready, receiver)) => {
#[cfg(feature="cache")]
{
CACHE.write()
.unwrap()
- .update_with_ready(&_ready);
+ .update_with_ready(&ready);
}
+ let shard = Arc::new(Mutex::new(shard));
+
+ dispatch(Event::Ready(ready),
+ shard.clone(),
+ self.framework.clone(),
+ self.data.clone(),
+ self.login_type,
+ self.event_store.clone());
+
let monitor_info = feature_framework! {{
MonitorInfo {
data: self.data.clone(),
@@ -812,7 +822,7 @@ impl Client {
gateway_url: gateway_url.clone(),
login_type: self.login_type,
receiver: receiver,
- shard: Arc::new(Mutex::new(shard)),
+ shard: shard,
shard_info: shard_info,
token: self.token.clone(),
}
@@ -823,7 +833,7 @@ impl Client {
gateway_url: gateway_url.clone(),
login_type: self.login_type,
receiver: receiver,
- shard: Arc::new(Mutex::new(shard)),
+ shard: shard,
shard_info: shard_info,
token: self.token.clone(),
}
@@ -1245,10 +1255,10 @@ fn monitor_shard(mut info: MonitorInfo) {
});
match boot {
- Ok((new_shard, _ready, new_receiver)) => {
+ Ok((new_shard, ready, new_receiver)) => {
#[cfg(feature="cache")]
{
- CACHE.write().unwrap().update_with_ready(&_ready);
+ CACHE.write().unwrap().update_with_ready(&ready);
}
*info.shard.lock().unwrap() = new_shard;
@@ -1256,6 +1266,13 @@ fn monitor_shard(mut info: MonitorInfo) {
boot_successful = true;
+ dispatch(Event::Ready(ready),
+ info.shard.clone(),
+ info.framework.clone(),
+ info.data.clone(),
+ info.login_type,
+ info.event_store.clone());
+
break;
},
Err(why) => warn!("Failed to boot shard: {:?}", why),