From 31e16c0865bb11933e0f1c84ae2c3dc4d1c4f6e9 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Wed, 20 Oct 2021 11:45:30 +0400 Subject: [PATCH] fix shard config --- config/default.json | 3 +++ gateway/src/shard/actions.rs | 6 +++++- gateway/src/shard/mod.rs | 5 ++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/default.json b/config/default.json index 51a8729..3aa90cb 100644 --- a/config/default.json +++ b/config/default.json @@ -28,5 +28,8 @@ "public_key": "", "client_id": 123 } + }, + "gateway": { + } } \ No newline at end of file diff --git a/gateway/src/shard/actions.rs b/gateway/src/shard/actions.rs index b6ef038..39a7ca2 100644 --- a/gateway/src/shard/actions.rs +++ b/gateway/src/shard/actions.rs @@ -57,6 +57,10 @@ impl Shard { .await } else { info!("Sending login"); + let mut shards: Option<[u64; 2]> = None; + if let Some(sharding) = self.config.shard.as_ref() { + shards = Some([sharding.current_shard, sharding.total_shards]); + } self._send(BaseMessage { t: None, sequence: None, @@ -69,7 +73,7 @@ impl Shard { browser: "Nova".to_string(), device: "Nova".to_string(), }, - shard: Some([0, 2]), + shard: shards, compress: Some(false), large_threshold: Some(500), presence: None, diff --git a/gateway/src/shard/mod.rs b/gateway/src/shard/mod.rs index b458451..55828d0 100644 --- a/gateway/src/shard/mod.rs +++ b/gateway/src/shard/mod.rs @@ -8,11 +8,10 @@ mod state; #[derive(Debug, Deserialize, Serialize, Default, Clone)] pub struct Sharding { - pub total_shards: i64, - pub current_shard: i64 + pub total_shards: u64, + pub current_shard: u64 } - #[derive(Debug, Deserialize, Serialize, Default, Clone)] pub struct ShardConfig { pub max_reconnects: usize, -- 2.39.5