pub struct SessionHandler { /* private fields */ }Available on crate feature
channels only.Expand description
Session management handler.
Wraps a SessionFactory, maintaining independent MessageHandler instances per user. Automatically handles timeout resets and keyword-based resets.
Implementations§
Source§impl SessionHandler
impl SessionHandler
Sourcepub fn new(
config: SessionConfig,
factory: impl SessionFactory + 'static,
) -> SessionHandler
pub fn new( config: SessionConfig, factory: impl SessionFactory + 'static, ) -> SessionHandler
Create a SessionHandler.
config: Session configurationfactory: Factory function for creating new sessions
Sourcepub fn with_defaults(factory: impl SessionFactory + 'static) -> SessionHandler
pub fn with_defaults(factory: impl SessionFactory + 'static) -> SessionHandler
Create with default configuration
Sourcepub fn with_on_session_end<F>(self, callback: F) -> SessionHandler
pub fn with_on_session_end<F>(self, callback: F) -> SessionHandler
Set session end callback (for resource cleanup, etc.)
Sourcepub fn active_sessions(&self) -> usize
pub fn active_sessions(&self) -> usize
Get the current number of active sessions
Trait Implementations§
Source§impl MessageHandler for SessionHandler
impl MessageHandler for SessionHandler
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
msg: InboundMessage,
) -> Pin<Box<dyn Future<Output = Result<OutboundMessage, ReactError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SessionHandler: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
msg: InboundMessage,
) -> Pin<Box<dyn Future<Output = Result<OutboundMessage, ReactError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SessionHandler: 'async_trait,
Handle an inbound message, returning an outbound message
Source§fn reply<'life0, 'async_trait>(
&'life0 self,
_msg: OutboundMessage,
) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SessionHandler: 'async_trait,
fn reply<'life0, 'async_trait>(
&'life0 self,
_msg: OutboundMessage,
) -> Pin<Box<dyn Future<Output = Result<(), ReactError>> + Send + 'async_trait>>where
'life0: 'async_trait,
SessionHandler: 'async_trait,
Send an outbound message back to the IM platform (implemented by the Channel itself)
Auto Trait Implementations§
impl Freeze for SessionHandler
impl !RefUnwindSafe for SessionHandler
impl Send for SessionHandler
impl Sync for SessionHandler
impl Unpin for SessionHandler
impl UnsafeUnpin for SessionHandler
impl !UnwindSafe for SessionHandler
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request