pub struct WsServer { /* private fields */ }Expand description
WebSocket 服务端
Implementations§
Source§impl WsServer
impl WsServer
Sourcepub fn new(
listen_addr: String,
config: ServerConfig,
connections: Arc<DashMap<u64, ClientConn>>,
router: Arc<RequestRouter>,
subscriptions: Option<Arc<SubscriptionManager>>,
) -> Self
pub fn new( listen_addr: String, config: ServerConfig, connections: Arc<DashMap<u64, ClientConn>>, router: Arc<RequestRouter>, subscriptions: Option<Arc<SubscriptionManager>>, ) -> Self
创建 WsServer,共享 TCP 的连接池、路由器、订阅管理器(无鉴权,向后兼容)
Sourcepub fn with_auth(
listen_addr: String,
config: ServerConfig,
deps: WsServerDeps,
key_store: Option<Arc<KeyStore>>,
counters: Option<Arc<RuntimeCounters>>,
) -> Self
pub fn with_auth( listen_addr: String, config: ServerConfig, deps: WsServerDeps, key_store: Option<Arc<KeyStore>>, counters: Option<Arc<RuntimeCounters>>, ) -> Self
v1.0 入口:同时接入 KeyStore + 共享 RuntimeCounters 做握手鉴权和 per-message
scope / 限额检查。key_store = None 或未配置时保持 legacy(全放行)。
Sourcepub fn with_server_time_store(self, store: Arc<ServerTimeAnchorStore>) -> Self
pub fn with_server_time_store(self, store: Arc<ServerTimeAnchorStore>) -> Self
Inject the shared backend server-time anchor for SDK-facing WS fields.
Sourcepub fn with_filter_registry(self, registry: Arc<FilterRegistry>) -> Self
pub fn with_filter_registry(self, registry: Arc<FilterRegistry>) -> Self
v1.4.104 阶段 3: 注入显式 FilterRegistry (跨 surface 共享同一份).
不调用此 setter 则 run() 时 fallback 到 FilterRegistry::with_defaults().
Sourcepub async fn run_until_shutdown(
&self,
shutdown_rx: Receiver<bool>,
) -> Result<()>
pub async fn run_until_shutdown( &self, shutdown_rx: Receiver<bool>, ) -> Result<()>
启动 WebSocket 服务端监听,并在 shutdown 信号到来时停止接受新连接。
Sourcepub async fn run_until_shutdown_with_listener_events(
&self,
shutdown_rx: Receiver<bool>,
listener_events: Option<ListenerBindEventSender>,
) -> Result<()>
pub async fn run_until_shutdown_with_listener_events( &self, shutdown_rx: Receiver<bool>, listener_events: Option<ListenerBindEventSender>, ) -> Result<()>
Run until shutdown and report the exact socket bind result to startup.
Auto Trait Implementations§
impl !RefUnwindSafe for WsServer
impl !UnwindSafe for WsServer
impl Freeze for WsServer
impl Send for WsServer
impl Sync for WsServer
impl Unpin for WsServer
impl UnsafeUnpin for WsServer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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