aboutsummaryrefslogtreecommitdiff
path: root/minecraft-protocol/src/write.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-15 23:10:55 -0600
committermat <github@matdoes.dev>2021-12-15 23:10:55 -0600
commit9642558f8f8d983a7087f15d68be8cf07a85f0c2 (patch)
tree5f0a967f005cd5db510a13ab290c8ad6669b25aa /minecraft-protocol/src/write.rs
parent72aefe871ca4983431b1a0b707b472e73ffea836 (diff)
downloadazalea-drasl-9642558f8f8d983a7087f15d68be8cf07a85f0c2.tar.xz
azalea
Diffstat (limited to 'minecraft-protocol/src/write.rs')
-rw-r--r--minecraft-protocol/src/write.rs27
1 files changed, 0 insertions, 27 deletions
diff --git a/minecraft-protocol/src/write.rs b/minecraft-protocol/src/write.rs
deleted file mode 100644
index 3d8540eb..00000000
--- a/minecraft-protocol/src/write.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-use tokio::{io::AsyncWriteExt, net::TcpStream};
-
-use crate::{mc_buf::Writable, packets::ProtocolPacket};
-
-pub async fn write_packet(packet: impl ProtocolPacket, stream: &mut TcpStream) {
- // TODO: implement compression
-
- // packet structure:
- // length (varint) + id (varint) + data
-
- // write the packet id
- let mut id_and_data_buf = vec![];
- id_and_data_buf.write_varint(packet.id() as i32);
- packet.write(&mut id_and_data_buf);
-
- // write the packet data
-
- // make a new buffer that has the length at the beginning
- // and id+data at the end
- let mut complete_buf: Vec<u8> = Vec::new();
- complete_buf.write_varint(id_and_data_buf.len() as i32);
- complete_buf.append(&mut id_and_data_buf);
-
- // finally, write and flush to the stream
- stream.write_all(&complete_buf).await.unwrap();
- stream.flush().await.unwrap();
-}