pub struct SessionServer { /* private fields */ }Implementations§
Source§impl SessionServer
impl SessionServer
Sourcepub fn new(node_id: NodeId, config: RealtimeConfig) -> Self
pub fn new(node_id: NodeId, config: RealtimeConfig) -> Self
Create a new session server.
pub fn node_id(&self) -> NodeId
pub fn config(&self) -> &RealtimeConfig
Sourcepub fn register_connection(
&self,
session_id: SessionId,
sender: Sender<RealtimeMessage>,
)
pub fn register_connection( &self, session_id: SessionId, sender: Sender<RealtimeMessage>, )
Register a new connection.
Sourcepub fn remove_connection(
&self,
session_id: SessionId,
) -> Option<Vec<SubscriptionId>>
pub fn remove_connection( &self, session_id: SessionId, ) -> Option<Vec<SubscriptionId>>
Remove a connection.
Sourcepub fn add_subscription(
&self,
session_id: SessionId,
subscription_id: SubscriptionId,
) -> Result<()>
pub fn add_subscription( &self, session_id: SessionId, subscription_id: SubscriptionId, ) -> Result<()>
Add a subscription to a connection.
Sourcepub fn remove_subscription(&self, subscription_id: SubscriptionId)
pub fn remove_subscription(&self, subscription_id: SubscriptionId)
Remove a subscription from a connection.
Sourcepub fn try_send_to_session(
&self,
session_id: SessionId,
message: RealtimeMessage,
) -> Result<(), SendError>
pub fn try_send_to_session( &self, session_id: SessionId, message: RealtimeMessage, ) -> Result<(), SendError>
Non-blocking send with backpressure. Returns false if client was evicted.
Sourcepub async fn send_to_session(
&self,
session_id: SessionId,
message: RealtimeMessage,
) -> Result<()>
pub async fn send_to_session( &self, session_id: SessionId, message: RealtimeMessage, ) -> Result<()>
Blocking send for initial data delivery where we need backpressure.
Sourcepub async fn broadcast_delta(
&self,
subscription_id: SubscriptionId,
delta: Delta<Value>,
) -> Result<()>
pub async fn broadcast_delta( &self, subscription_id: SubscriptionId, delta: Delta<Value>, ) -> Result<()>
Send a delta to all sessions subscribed to a subscription.
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get connection count.
Sourcepub fn subscription_count(&self) -> usize
pub fn subscription_count(&self) -> usize
Get subscription count.
Sourcepub fn stats(&self) -> SessionStats
pub fn stats(&self) -> SessionStats
Get server statistics.
Sourcepub fn cleanup_stale(&self, max_idle: Duration)
pub fn cleanup_stale(&self, max_idle: Duration)
Cleanup stale connections.
Auto Trait Implementations§
impl Freeze for SessionServer
impl !RefUnwindSafe for SessionServer
impl Send for SessionServer
impl Sync for SessionServer
impl Unpin for SessionServer
impl UnsafeUnpin for SessionServer
impl UnwindSafe for SessionServer
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 more