diff options
Diffstat (limited to 'client-native-lib/src')
-rw-r--r-- | client-native-lib/src/instance.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/client-native-lib/src/instance.rs b/client-native-lib/src/instance.rs index cd720f1..162241d 100644 --- a/client-native-lib/src/instance.rs +++ b/client-native-lib/src/instance.rs @@ -44,6 +44,24 @@ impl Instance { }) } + pub async fn spawn_ping(self: &Arc<Self>) { + let blub = self.clone(); + tokio::spawn(async move { + loop { + blub.ping(); + } + }); + } + + pub async fn ping(&self) { + self.conn + .send + .write() + .await + .send(ServerboundPacket::Ping) + .await; + } + pub async fn my_id(&self) -> usize { self.my_id.read().await.expect("not initialized yet") } |