From 4a44c58444c901d939a8594669c819ab2bfbac13 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 7 Dec 2021 22:12:16 +0000 Subject: keep doing packet stuff --- minecraft-protocol/src/connection.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'minecraft-protocol/src/connection.rs') 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: -- cgit v1.2.3