mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 14:42:32 +00:00
fixes unwrap on write_raw_packet(...) (#128)
This commit is contained in:
parent
fd1c99e74a
commit
73be589e7f
1 changed files with 12 additions and 4 deletions
|
@ -10,7 +10,7 @@ use azalea_protocol::{
|
|||
use bevy_ecs::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use thiserror::Error;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::sync::mpsc::{self, error::SendError};
|
||||
use tracing::error;
|
||||
|
||||
/// A component for clients that can read and write packets to the server. This
|
||||
|
@ -51,6 +51,12 @@ pub enum WritePacketError {
|
|||
},
|
||||
#[error(transparent)]
|
||||
Encoding(#[from] azalea_protocol::write::PacketEncodeError),
|
||||
#[error(transparent)]
|
||||
SendError {
|
||||
#[from]
|
||||
#[backtrace]
|
||||
source: SendError<Vec<u8>>,
|
||||
},
|
||||
}
|
||||
|
||||
impl RawConnection {
|
||||
|
@ -88,11 +94,12 @@ impl RawConnection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn write_raw_packet(&self, raw_packet: Vec<u8>) {
|
||||
pub fn write_raw_packet(&self, raw_packet: Vec<u8>) -> Result<(), WritePacketError> {
|
||||
self.writer
|
||||
.outgoing_packets_sender
|
||||
.send(raw_packet)
|
||||
.unwrap();
|
||||
.map_err(WritePacketError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Write the packet with the given state to the server.
|
||||
|
@ -106,7 +113,8 @@ impl RawConnection {
|
|||
packet: P,
|
||||
) -> Result<(), WritePacketError> {
|
||||
let raw_packet = serialize_packet(&packet)?;
|
||||
self.write_raw_packet(raw_packet);
|
||||
self.write_raw_packet(raw_packet)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue