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 bevy_ecs::prelude::*;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc::{self, error::SendError};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
/// A component for clients that can read and write packets to the server. This
|
/// A component for clients that can read and write packets to the server. This
|
||||||
|
@ -51,6 +51,12 @@ pub enum WritePacketError {
|
||||||
},
|
},
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Encoding(#[from] azalea_protocol::write::PacketEncodeError),
|
Encoding(#[from] azalea_protocol::write::PacketEncodeError),
|
||||||
|
#[error(transparent)]
|
||||||
|
SendError {
|
||||||
|
#[from]
|
||||||
|
#[backtrace]
|
||||||
|
source: SendError<Vec<u8>>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RawConnection {
|
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
|
self.writer
|
||||||
.outgoing_packets_sender
|
.outgoing_packets_sender
|
||||||
.send(raw_packet)
|
.send(raw_packet)
|
||||||
.unwrap();
|
.map_err(WritePacketError::from)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write the packet with the given state to the server.
|
/// Write the packet with the given state to the server.
|
||||||
|
@ -106,7 +113,8 @@ impl RawConnection {
|
||||||
packet: P,
|
packet: P,
|
||||||
) -> Result<(), WritePacketError> {
|
) -> Result<(), WritePacketError> {
|
||||||
let raw_packet = serialize_packet(&packet)?;
|
let raw_packet = serialize_packet(&packet)?;
|
||||||
self.write_raw_packet(raw_packet);
|
self.write_raw_packet(raw_packet)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue