Refactor
Updated handlers by spliting the TcpStream in half to allow reading and writing data at the same time. This fixes an issue where you are unable to get chat messages until the client sends a packet to the server Fixed client id's by adding the id manager Added shout chat handling
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::metrics::PACKETS_SENT;
|
||||
use crate::packet_type::PacketType;
|
||||
use bincode::{Decode, Encode};
|
||||
use std::error::Error;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::io::{AsyncWriteExt, WriteHalf};
|
||||
use tokio::net::TcpStream;
|
||||
use tracing::{debug, error};
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Packet {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn send_packet(stream: &mut TcpStream, packet: &Packet) -> Result<(), std::io::Error> {
|
||||
pub async fn send_packet(stream: &mut WriteHalf<TcpStream>, packet: &Packet) -> Result<(), std::io::Error> {
|
||||
let data = packet.to_raw();
|
||||
debug!("Sending '{:#X}' bytes of data. {:?}", data.len(), data);
|
||||
PACKETS_SENT.inc();
|
||||
|
||||
Reference in New Issue
Block a user