Struct autoconnect_ws_sm::WebPushClient

source ·
pub struct WebPushClient {
    pub uaid: Uuid,
    pub uid: Uuid,
    pub ua_info: UserAgentInfo,
    /* private fields */
}
Expand description

A WebPush Client that’s successfully identified itself to the server via a Hello message.

The webpush_ws handler feeds input from both the WebSocket connection (ClientMessage) and the ClientRegistry (ServerNotification) triggered by autoendpoint to this type’s on_client_msg and on_server_notif methods whose impls reside in their own modules.

Note the check_storage method (in the on_server_notif module) is triggered by both a ServerNotification and also the new constructor

Fields§

§uaid: Uuid

Push User Agent identifier. Each Push client recieves a unique UAID

§uid: Uuid

Unique, local (to each autoconnect instance) identifier

§ua_info: UserAgentInfo

The User Agent information block derived from the User-Agent header

Implementations§

source§

impl WebPushClient

source

pub async fn on_client_msg( &mut self, msg: ClientMessage, ) -> Result<Vec<ServerMessage>, SMError>

Handle a WebPush ClientMessage sent from the user agent over the WebSocket for this user

source§

impl WebPushClient

source

pub async fn on_server_notif( &mut self, snotif: ServerNotification, ) -> Result<Vec<ServerMessage>, SMError>

Handle a ServerNotification for this user

ServerNotification::Disconnect is emitted by the same autoconnect node recieving it when a User has logged into that same node twice to “Ghost” (disconnect) the first user’s session for its second session.

Other variants are emitted by autoendpoint

source

pub fn on_server_notif_shutdown(&mut self, snotif: ServerNotification)

After disconnecting from the ClientRegistry, moves any queued Direct Push Notifications to unacked_direct_notifs (to be stored in the db on shutdown)

source§

impl WebPushClient

source

pub async fn new( uaid: Uuid, ua: String, broadcast_subs: BroadcastSubs, flags: ClientFlags, connected_at: u64, current_timestamp: Option<u64>, deferred_add_user: Option<User>, app_state: Arc<AppState>, ) -> Result<(Self, Vec<ServerMessage>), SMError>

source

pub fn app_settings(&self) -> &Settings

Return a reference to AppState’s Settings

source

pub async fn registry_connect(&self) -> UnboundedReceiver<ServerNotification>

Connect this WebPushClient to the ClientRegistry

Returning a Stream of ServerNotifications from the ClientRegistry

source

pub async fn registry_disconnect(&self)

Disconnect this WebPushClient from the ClientRegistry

source

pub async fn broadcast_delta(&mut self) -> Option<Vec<Broadcast>>

Return the difference between the Client’s Broadcast Subscriptions and the this server’s Broadcasts

source

pub fn shutdown(&mut self, reason: Option<String>)

Cleanup after the session has ended

source

pub fn add_sentry_info(self, event: &mut Event<'_>)

Add User information and tags for this Client to a Sentry Event

Trait Implementations§

source§

impl Debug for WebPushClient

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more