pub struct Session { /* private fields */ }Expand description
One connection to one network’s websocket.
Implementations§
Source§impl Session
impl Session
Sourcepub fn tick(&mut self, now: u64) -> Tick
pub fn tick(&mut self, now: u64) -> Tick
What the socket needs at now: a ping after Timing::ping_after_ms with no pong or
data (once, until one arrives or as long again passes), or a reconnect after
Timing::silent_ms of nothing at all.
Sourcepub fn closed(&mut self, now: u64, random: u64) -> Retry
pub fn closed(&mut self, now: u64, random: u64) -> Retry
The socket closed at now, or a connect failed. Gives how long to wait before the next
connect, and the posts left unanswered. The wait doubles from
Timing::first_retry_ms to Timing::last_retry_ms and random adds up to a quarter
more, so many clients dropped at once do not return at once. It starts over after a
socket that held (Timing::steady_ms). There is no last attempt.
Source§impl Session
impl Session
Sourcepub fn new(network: Network) -> Self
pub fn new(network: Network) -> Self
A closed session on network, with the venue’s limits and the default timing.
Sourcepub const fn with_limits(self, limits: Limits) -> Self
pub const fn with_limits(self, limits: Limits) -> Self
The limits are per IP: sessions sharing one split them.
pub const fn with_timing(self, timing: Timing) -> Self
pub const fn network(&self) -> Network
pub const fn is_open(&self) -> bool
Sourcepub fn wanted(&self) -> &[Subscription]
pub fn wanted(&self) -> &[Subscription]
What this session subscribes to on every socket, in the order it was asked for.
Sourcepub fn subscribe(
&mut self,
subscription: Subscription,
) -> Result<Option<String>, Refused>
pub fn subscribe( &mut self, subscription: Subscription, ) -> Result<Option<String>, Refused>
Wants subscription from now on, on this socket and every later one. Gives the frame to
send when the socket is open and it is new; nothing when it was already wanted. Past the
limits, or when the venue would not take it, it is refused and not kept.
Sourcepub fn unsubscribe(&mut self, subscription: &Subscription) -> Option<String>
pub fn unsubscribe(&mut self, subscription: &Subscription) -> Option<String>
Stops wanting subscription. Gives the frame to send when the socket is open and it was
wanted.
Sourcepub fn post(&mut self, request: &Post) -> Result<(u64, String), Refused>
pub fn post(&mut self, request: &Post) -> Result<(u64, String), Refused>
Gives the next post’s id and its frame. Only on an open socket, and only while fewer than the limit are waiting for an answer.