pub struct RaknetSocket { /* private fields */ }Expand description
A RakNet connection backed by a UDP socket.
Implementations§
Source§impl RaknetSocket
impl RaknetSocket
Sourcepub async fn from(
addr: &SocketAddr,
s: &Arc<UdpSocket>,
receiver: Receiver<Vec<u8>>,
mtu: u16,
collecter: Arc<Mutex<Sender<SocketAddr>>>,
raknet_version: u8,
) -> Self
pub async fn from( addr: &SocketAddr, s: &Arc<UdpSocket>, receiver: Receiver<Vec<u8>>, mtu: u16, collecter: Arc<Mutex<Sender<SocketAddr>>>, raknet_version: u8, ) -> Self
Create a RakNet socket for an established UDP connection.
This constructor is used internally by [RaknetListener].
Sourcepub async fn connect(addr: &SocketAddr) -> Result<Self>
pub async fn connect(addr: &SocketAddr) -> Result<Self>
pub async fn connect_with_version( addr: &SocketAddr, raknet_version: u8, ) -> Result<Self>
Sourcepub async fn send(&self, buf: &[u8], reliability: Reliability) -> Result<()>
pub async fn send(&self, buf: &[u8], reliability: Reliability) -> Result<()>
Send a Bedrock game packet.
The packet must begin with 0xfe. Payloads that exceed the negotiated MTU return RaknetError::PacketSizeExceedMTU.
§Example
ⓘ
let socket = RaknetSocket::connect("127.0.0.1:19132".parse().unwrap()).await.unwrap();
socket.send(&[0xfe], Reliability::ReliableOrdered).await.unwrap();Sourcepub async fn send_with_order_channel(
&self,
buf: &[u8],
reliability: Reliability,
order_channel: u8,
) -> Result<()>
pub async fn send_with_order_channel( &self, buf: &[u8], reliability: Reliability, order_channel: u8, ) -> Result<()>
Send a packet on a specific RakNet ordering channel.
Each ordering channel has an independent reliable-ordered sequence. The channel is relevant to ordered and sequenced reliability modes; unordered modes do not carry an ordering channel on the wire.
Sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Sourcepub fn raknet_version(&self) -> Result<u8>
pub fn raknet_version(&self) -> Result<u8>
Return the RakNet protocol version used by this connection.
Sourcepub fn set_loss_rate(&mut self, stage: u8)
pub fn set_loss_rate(&mut self, stage: u8)
Trait Implementations§
Source§impl Drop for RaknetSocket
impl Drop for RaknetSocket
Auto Trait Implementations§
impl !RefUnwindSafe for RaknetSocket
impl !UnwindSafe for RaknetSocket
impl Freeze for RaknetSocket
impl Send for RaknetSocket
impl Sync for RaknetSocket
impl Unpin for RaknetSocket
impl UnsafeUnpin for RaknetSocket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more