pub struct RaknetListener { /* private fields */ }
Expand description

Implementation of Raknet Server.

Implementations

Creates a new RaknetListener which will be bound to the specified address.

Example
let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
listener.listen().await;
let mut socket = socket = listener.accept().await.unwrap();

Creates a new RaknetListener from a UdpSocket.

Example
let raw_socket = std::net::UdpSocket::bind("127.0.0.1:19132").unwrap();
let listener = RaknetListener::from_std(raw_socket);

Listen to a RaknetListener

This method must be called before calling RaknetListener::accept()

Example
let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
listener.listen().await;

Waiting for and receiving new Raknet connections, returning a Raknet socket

Call this method must be after calling RaknetListener::listen()

Example
let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
listener.listen().await;
let mut socket = listener.accept().await.unwrap();

Set the current motd, this motd will be provided to the client in the unconnected pong.

Call this method must be after calling RaknetListener::listen()

Example
let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
listener.set_motd("Another Minecraft Server" , 999999 , "486" , "1.18.11", "Survival" , 19132).await;

Get the current motd, this motd will be provided to the client in the unconnected pong.

Example
let mut listener = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
let motd = listener.get_motd().await;

Returns the socket address of the local half of this Raknet connection.

Example
let mut socket = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
assert_eq!(socket.local_addr().unwrap().ip(), IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));

Close Raknet Server and all connections.

Example
let mut socket = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
socket.close().await;

Set full motd string.

Example
let mut socket = RaknetListener::bind("127.0.0.1:19132".parse().unwrap()).await.unwrap();
socket.set_full_motd("motd").await;

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.