diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gateway/shard.rs | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs index f3c072c..87940fd 100644 --- a/src/gateway/shard.rs +++ b/src/gateway/shard.rs @@ -128,6 +128,14 @@ impl Shard { -> Result<Shard> { let client = connect(&*ws_url.lock().unwrap())?; + let current_presence = (None, OnlineStatus::Online, false); + let heartbeat_instants = (None, None); + let heartbeat_interval = None; + let last_heartbeat_acknowledged = true; + let seq = 0; + let stage = ConnectionStage::Handshake; + let session_id = None; + Ok(feature_voice! { { let (tx, rx) = mpsc::channel(); @@ -136,20 +144,32 @@ impl Shard { Shard { client, + current_presence, + heartbeat_instants, + heartbeat_interval, + last_heartbeat_acknowledged, + seq, + stage, token, shard_info, + session_id, ws_url, manager: VoiceManager::new(tx, user.id), manager_rx: rx, - .. Default::default() } } else { Shard { client, + current_presence, + heartbeat_instants, + heartbeat_interval, + last_heartbeat_acknowledged, + seq, + stage, token, + session_id, shard_info, ws_url, - .. Default::default() } } }) @@ -1021,32 +1041,9 @@ fn set_client_timeout(client: &mut WsClient) -> Result<()> { fn build_gateway_url(base: &str) -> Result<Url> { Url::parse(&format!("{}?v={}", base, constants::GATEWAY_VERSION)) - .map_err(|_| Error::Gateway(GatewayError::BuildingUrl)) -} + .map_err(|why| { + warn!("Error building gateway URL with base `{}`: {:?}", base, why); -impl Default for Shard { - fn default() -> Self { - #[cfg(feature = "voice")] - let (tx, rx) = mpsc::channel(); - #[cfg(feature = "voice")] - let user = http::get_current_user().unwrap(); - - Shard { - client: connect(&String::new()).unwrap(), - current_presence: (None, OnlineStatus::Online, false), - heartbeat_instants: (None, None), - heartbeat_interval: None, - last_heartbeat_acknowledged: true, - seq: 0, - stage: ConnectionStage::Handshake, - token: Arc::new(Mutex::new(String::new())), - session_id: None, - shard_info: [0; 2], - ws_url: Arc::new(Mutex::new(String::new())), - #[cfg(feature = "voice")] - manager: VoiceManager::new(tx, user.id), - #[cfg(feature = "voice")] - manager_rx: rx, - } - } + Error::Gateway(GatewayError::BuildingUrl) + }) } |