pub struct SessionFacade<'a, H: SessionFacadeHandler> { /* private fields */ }Expand description
Session-id based facade over server events.
Implementations§
Source§impl<'a, H: SessionFacadeHandler> SessionFacade<'a, H>
impl<'a, H: SessionFacadeHandler> SessionFacade<'a, H>
Sourcepub fn new(server: &'a mut RaknetServer, handler: &'a mut H) -> Self
pub fn new(server: &'a mut RaknetServer, handler: &'a mut H) -> Self
Creates a new session facade with an empty SessionIdAdapter.
Sourcepub fn with_adapter(
server: &'a mut RaknetServer,
handler: &'a mut H,
adapter: SessionIdAdapter,
) -> Self
pub fn with_adapter( server: &'a mut RaknetServer, handler: &'a mut H, adapter: SessionIdAdapter, ) -> Self
Creates a session facade with a caller-provided adapter.
Sourcepub async fn next(&mut self) -> Result<bool>
pub async fn next(&mut self) -> Result<bool>
Polls one event and dispatches it to the session handler.
Returns Ok(false) when the server event stream is closed.
Sourcepub async fn run(&mut self) -> Result<()>
pub async fn run(&mut self) -> Result<()>
Runs facade loop until stream closure or callback error.
Sourcepub fn server(&self) -> &RaknetServer
pub fn server(&self) -> &RaknetServer
Returns immutable access to wrapped server.
Sourcepub fn server_mut(&mut self) -> &mut RaknetServer
pub fn server_mut(&mut self) -> &mut RaknetServer
Returns mutable access to wrapped server.
Sourcepub fn handler_mut(&mut self) -> &mut H
pub fn handler_mut(&mut self) -> &mut H
Returns mutable access to wrapped handler.
Sourcepub fn adapter(&self) -> &SessionIdAdapter
pub fn adapter(&self) -> &SessionIdAdapter
Returns immutable access to the session-id adapter.
Sourcepub fn adapter_mut(&mut self) -> &mut SessionIdAdapter
pub fn adapter_mut(&mut self) -> &mut SessionIdAdapter
Returns mutable access to the session-id adapter.
Sourcepub fn session_id_for_peer(&self, peer_id: PeerId) -> Option<SessionId>
pub fn session_id_for_peer(&self, peer_id: PeerId) -> Option<SessionId>
Resolves PeerId to session id.
Sourcepub fn peer_id_for_session(&self, session_id: SessionId) -> Option<PeerId>
pub fn peer_id_for_session(&self, session_id: SessionId) -> Option<PeerId>
Resolves session id to PeerId.
Sourcepub fn peer_id_for_session_i32(&self, session_id: i32) -> Option<PeerId>
pub fn peer_id_for_session_i32(&self, session_id: i32) -> Option<PeerId>
Resolves i32 session id to PeerId.
Sourcepub async fn send(
&mut self,
session_id: SessionId,
payload: impl Into<Bytes>,
) -> Result<()>
pub async fn send( &mut self, session_id: SessionId, payload: impl Into<Bytes>, ) -> Result<()>
Sends payload to a session with default send options.
Sourcepub async fn send_with_options(
&mut self,
session_id: SessionId,
payload: impl Into<Bytes>,
options: SendOptions,
) -> Result<()>
pub async fn send_with_options( &mut self, session_id: SessionId, payload: impl Into<Bytes>, options: SendOptions, ) -> Result<()>
Sends payload to a session with explicit send options.
Sourcepub async fn send_with_receipt(
&mut self,
session_id: SessionId,
payload: impl Into<Bytes>,
receipt_id: u64,
) -> Result<()>
pub async fn send_with_receipt( &mut self, session_id: SessionId, payload: impl Into<Bytes>, receipt_id: u64, ) -> Result<()>
Sends payload to a session and tracks a receipt id.
Sourcepub async fn disconnect(&mut self, session_id: SessionId) -> Result<()>
pub async fn disconnect(&mut self, session_id: SessionId) -> Result<()>
Disconnects a session.