diff options
| author | Zeyla Hellyer <[email protected]> | 2017-06-13 09:42:22 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-06-13 09:42:22 -0700 |
| commit | d48dbeb07b1040d4f401f2cdfc7722f4872bcb91 (patch) | |
| tree | c812a2dc348206022f7da5f560ef1361a967ce18 /src | |
| parent | Deserialize embed footers (diff) | |
| download | serenity-d48dbeb07b1040d4f401f2cdfc7722f4872bcb91.tar.xz serenity-d48dbeb07b1040d4f401f2cdfc7722f4872bcb91.zip | |
Only set shard timeout after a READY is received
Diffstat (limited to 'src')
| -rw-r--r-- | src/gateway/shard.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs index 2dcdf38..44ce833 100644 --- a/src/gateway/shard.rs +++ b/src/gateway/shard.rs @@ -143,6 +143,8 @@ impl Shard { let event = client.recv_json(GatewayEvent::decode)?; let (ready, sequence) = prep::parse_ready(event, &mut client, &identification)?; + set_client_timeout(&mut client)?; + Ok((feature_voice! {{ let (tx, rx) = mpsc::channel(); @@ -848,12 +850,14 @@ fn connect(base_url: &str) -> Result<WsClient> { let url = prep::build_gateway_url(base_url)?; let client = ClientBuilder::from_url(&url).connect_secure(None)?; + Ok(client) +} + +fn set_client_timeout(client: &mut WsClient) -> Result<()> { let timeout = StdDuration::from_millis(250); - { - let stream = client.stream_ref().as_tcp(); - stream.set_read_timeout(Some(timeout))?; - } + let stream = client.stream_ref().as_tcp(); + stream.set_read_timeout(Some(timeout))?; - Ok(client) + Ok(()) } |