pub struct RaknetServer { /* private fields */ }Implementations§
Source§impl RaknetServer
impl RaknetServer
Sourcepub fn builder() -> RaknetServerBuilder
pub fn builder() -> RaknetServerBuilder
Creates a default builder.
Sourcepub async fn bind(bind_addr: SocketAddr) -> Result<Self>
pub async fn bind(bind_addr: SocketAddr) -> Result<Self>
Starts server with default configs and provided bind address.
Sourcepub fn facade(&mut self) -> ServerFacade<'_>
pub fn facade(&mut self) -> ServerFacade<'_>
Creates closure-based facade over server event stream.
Sourcepub fn event_facade<'a, H: EventFacadeHandler>(
&'a mut self,
handler: &'a mut H,
) -> EventFacade<'a, H>
pub fn event_facade<'a, H: EventFacadeHandler>( &'a mut self, handler: &'a mut H, ) -> EventFacade<'a, H>
Creates trait-based event facade over server event stream.
Sourcepub fn session_facade<'a, H: SessionFacadeHandler>(
&'a mut self,
handler: &'a mut H,
) -> SessionFacade<'a, H>
pub fn session_facade<'a, H: SessionFacadeHandler>( &'a mut self, handler: &'a mut H, ) -> SessionFacade<'a, H>
Creates session-id based facade over server event stream.
Sourcepub async fn start_with_configs(
transport_config: TransportConfig,
runtime_config: ShardedRuntimeConfig,
) -> Result<Self>
pub async fn start_with_configs( transport_config: TransportConfig, runtime_config: ShardedRuntimeConfig, ) -> Result<Self>
Starts server from explicit transport and runtime configurations.
Sourcepub fn peer_addr(&self, peer_id: PeerId) -> Option<SocketAddr>
pub fn peer_addr(&self, peer_id: PeerId) -> Option<SocketAddr>
Returns peer socket address for a peer id, if present.
Sourcepub fn peer_shard(&self, peer_id: PeerId) -> Option<usize>
pub fn peer_shard(&self, peer_id: PeerId) -> Option<usize>
Returns shard id owning a peer, if present.
Sourcepub fn peer_id_for_addr(&self, addr: SocketAddr) -> Option<PeerId>
pub fn peer_id_for_addr(&self, addr: SocketAddr) -> Option<PeerId>
Resolves peer id by remote address, if known.
Sourcepub async fn send(
&self,
peer_id: PeerId,
payload: impl Into<Bytes>,
) -> Result<()>
pub async fn send( &self, peer_id: PeerId, payload: impl Into<Bytes>, ) -> Result<()>
Sends payload with default send options.
Sourcepub async fn send_with_options(
&self,
peer_id: PeerId,
payload: impl Into<Bytes>,
options: SendOptions,
) -> Result<()>
pub async fn send_with_options( &self, peer_id: PeerId, payload: impl Into<Bytes>, options: SendOptions, ) -> Result<()>
Sends payload with explicit send options.
Sourcepub async fn send_with_receipt(
&self,
peer_id: PeerId,
payload: impl Into<Bytes>,
receipt_id: u64,
) -> Result<()>
pub async fn send_with_receipt( &self, peer_id: PeerId, payload: impl Into<Bytes>, receipt_id: u64, ) -> Result<()>
Sends payload and tracks a receipt id.
Sourcepub async fn send_with_options_and_receipt(
&self,
peer_id: PeerId,
payload: impl Into<Bytes>,
options: SendOptions,
receipt_id: u64,
) -> Result<()>
pub async fn send_with_options_and_receipt( &self, peer_id: PeerId, payload: impl Into<Bytes>, options: SendOptions, receipt_id: u64, ) -> Result<()>
Sends payload with explicit send options and receipt id.
Sourcepub async fn disconnect(&mut self, peer_id: PeerId) -> Result<()>
pub async fn disconnect(&mut self, peer_id: PeerId) -> Result<()>
Requests disconnection and emits a local disconnect event.
Sourcepub async fn next_event(&mut self) -> Option<RaknetServerEvent>
pub async fn next_event(&mut self) -> Option<RaknetServerEvent>
Polls next server event.
Returns None when runtime event channel is closed.