aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/connection.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-07 22:12:16 +0000
committermat <github@matdoes.dev>2021-12-07 22:12:16 +0000
commit4a44c58444c901d939a8594669c819ab2bfbac13 (patch)
tree5085824e8af8bb9209f7defa178f1010fc29e436 /minecraft-protocol/src/connection.rs
parent9c14b3f32346f071ad12faf86105f5fd3ce03959 (diff)
downloadazalea-drasl-4a44c58444c901d939a8594669c819ab2bfbac13.tar.xz
keep doing packet stuff
Diffstat (limited to 'minecraft-protocol/src/connection.rs')
-rw-r--r--minecraft-protocol/src/connection.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/minecraft-protocol/src/connection.rs b/minecraft-protocol/src/connection.rs
index ee03b5e5..a162bb6b 100644
--- a/minecraft-protocol/src/connection.rs
+++ b/minecraft-protocol/src/connection.rs
@@ -1,4 +1,4 @@
-//! Handle sending and receiving packets with a server.
+//! parse sending and receiving packets with a server.
use crate::packets::ConnectionProtocol;
use crate::{mc_buf, packets::Packet, ServerIpAddress};
@@ -41,6 +41,10 @@ impl Connection {
})
}
+ pub fn switch_state(&mut self, state: ConnectionProtocol) {
+ self.state = state;
+ }
+
pub async fn read_packet(&mut self) -> Result<(), String> {
// what this does:
// 1. reads the first 5 bytes, probably only some of this will be used to get the packet length
@@ -68,7 +72,7 @@ impl Connection {
}
/// Write a packet to the server
- pub async fn send_packet(&mut self, packet: &dyn Packet) {
+ pub async fn send_packet(&mut self, packet: &impl Packet) {
// TODO: implement compression
// packet structure: