pub struct ChatStreamHandler<B: ChatBackend> { /* private fields */ }websocket only.Expand description
The ChatStreamEnable / ChatStreamDisable handler of one WebSocket
connection; see the module docs.
ChatStreamEnablereplaces the subscription throughEphemeralSubscription::replace_withwith theCompanionStreamsgiven towith_companions. Its error becomes theRequestError(invalidArguments, with the message’sidasrequestId) and leaves the subscription unchanged. A malformed message isnotRequest.ChatStreamDisableclears it, silently, whether or not one was active.- Closing the connection clears it and stops delivery.
The companion values "vtc" and "scene" only switch the companion
handler’s alias on: register
on_subscription_change observers for
them (jmap-chat-vtc-server and jmap-chat-scene-server do).
Implementations§
Source§impl<B: ChatBackend> ChatStreamHandler<B>
impl<B: ChatBackend> ChatStreamHandler<B>
Sourcepub fn new(
backend: Arc<B>,
caller: B::CallerCtx,
accounts: impl IntoIterator<Item = Id>,
hub: &ChatEventHub,
) -> Self
pub fn new( backend: Arc<B>, caller: B::CallerCtx, accounts: impl IntoIterator<Item = Id>, hub: &ChatEventHub, ) -> Self
The handler of a connection authenticated as caller, receiving
the events of accounts (the accounts whose Chats and
ChatContacts the owner sees, usually the owner’s own) from hub.
No companion value is recognized and the default
ChatStreamLimits apply.
Sourcepub fn with_companions(self, companions: CompanionStreams) -> Self
pub fn with_companions(self, companions: CompanionStreams) -> Self
The companion WebSocket capabilities the server advertises, which
decide whether "vtc" and "scene" in dataTypes are recognized.
Sourcepub fn companions(&self) -> CompanionStreams
pub fn companions(&self) -> CompanionStreams
The companion capabilities in effect.
Sourcepub fn with_limits(self, limits: ChatStreamLimits) -> Self
pub fn with_limits(self, limits: ChatStreamLimits) -> Self
Replace the outbound rate limits.
Sourcepub fn on_subscription_change(
self,
observer: impl FnMut(&EphemeralSubscription) + Send + 'static,
) -> Self
pub fn on_subscription_change( self, observer: impl FnMut(&EphemeralSubscription) + Send + 'static, ) -> Self
Call observer with the subscription each time it changes: after
a successful ChatStreamEnable, after ChatStreamDisable, and
with the empty subscription when the connection closes. Observers
run in the order added, before the next client message is read.
Sourcepub fn subscription(&self) -> EphemeralSubscription
pub fn subscription(&self) -> EphemeralSubscription
The connection’s current subscription.
Trait Implementations§
Source§impl<B: ChatBackend> Debug for ChatStreamHandler<B>
impl<B: ChatBackend> Debug for ChatStreamHandler<B>
Source§impl<B: ChatBackend> Drop for ChatStreamHandler<B>
impl<B: ChatBackend> Drop for ChatStreamHandler<B>
Source§impl<B: ChatBackend> ExtensionHandler for ChatStreamHandler<B>
impl<B: ChatBackend> ExtensionHandler for ChatStreamHandler<B>
Source§fn message_types(&self) -> &[&str]
fn message_types(&self) -> &[&str]
@types this handler takes. Read once, by
Connection::with_extension.Source§fn start(&mut self, events: ExtensionSender)
fn start(&mut self, events: ExtensionSender)
Source§async fn handle(&mut self, message: ExtensionMessage) -> Result<(), JmapError>
async fn handle(&mut self, message: ExtensionMessage) -> Result<(), JmapError>
RequestError”). Err is sent as an RFC 8887 §4.3.4
RequestError with the message’s id as
requestId, through
RequestHandler::prepare_problem;
its extra members become problem-details members (for example
the Scene draft’s regionIds on a forbidden error).