pub struct EventDispatcherHandler { /* private fields */ }Expand description
WebSocket 事件分发处理器。
目前支持两类分发目标:
payload_sender(...):把原始负载转发到 channelregister_raw(...):注册原始事件处理器
Implementations§
Source§impl EventDispatcherHandler
impl EventDispatcherHandler
Sourcepub const RAW_EVENT_KEY: &'static str = "raw"
pub const RAW_EVENT_KEY: &'static str = "raw"
通配原始事件处理器 key。
Sourcepub fn builder() -> EventDispatcherHandler
pub fn builder() -> EventDispatcherHandler
创建新的事件分发构建器。
Sourcepub fn build(self) -> EventDispatcherHandler
pub fn build(self) -> EventDispatcherHandler
完成构建。
Sourcepub fn payload_sender(
self,
payload_tx: UnboundedSender<Vec<u8>>,
) -> EventDispatcherHandler
pub fn payload_sender( self, payload_tx: UnboundedSender<Vec<u8>>, ) -> EventDispatcherHandler
配置 channel 转发器,用于把原始负载发往外部任务。
Sourcepub fn register_raw<S, H>(
self,
key: S,
handler: H,
) -> Result<EventDispatcherHandler, String>
pub fn register_raw<S, H>( self, key: S, handler: H, ) -> Result<EventDispatcherHandler, String>
注册原始事件处理器。
- 传入
"raw"会接收所有原始事件负载 - 传入具体
event_type(例如"im.message.receive_v1")只会接收匹配事件
Trait Implementations§
Source§impl Clone for EventDispatcherHandler
impl Clone for EventDispatcherHandler
Source§fn clone(&self) -> EventDispatcherHandler
fn clone(&self) -> EventDispatcherHandler
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EventDispatcherHandler
impl !RefUnwindSafe for EventDispatcherHandler
impl Send for EventDispatcherHandler
impl Sync for EventDispatcherHandler
impl Unpin for EventDispatcherHandler
impl UnsafeUnpin for EventDispatcherHandler
impl !UnwindSafe for EventDispatcherHandler
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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