Struct CollaborationServer

Source
pub struct CollaborationServer { /* private fields */ }
Expand description

YrsManager 的包装器,用于处理动态房间创建和广播组管理

Implementations§

Source§

impl CollaborationServer

Source

pub fn new(yrs_manager: Arc<YrsManager>, port: u16) -> Self

Source

pub fn with_sync_service( yrs_manager: Arc<YrsManager>, sync_service: Arc<SyncService>, port: u16, ) -> Self

使用现有的 SyncService 创建服务器

Source

pub async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible>

自定义错误处理器

Source

pub async fn offline_room(&self, room_id: &str, save_data: bool) -> Result<bool>

房间下线 - 优雅关闭房间

  1. 通知所有客户端房间即将关闭
  2. 等待客户端完成当前操作
  3. 保存数据(可选)
  4. 清理资源
Source

pub async fn force_offline_room(&self, room_id: &str) -> Result<bool>

强制房间下线 - 紧急情况使用

Source

pub async fn offline_rooms( &self, room_ids: &[String], save_data: bool, ) -> Result<Vec<(String, bool)>>

批量下线房间

Source

pub fn get_active_rooms(&self) -> Vec<String>

获取所有活跃房间列表

Source

pub async fn get_rooms_stats(&self) -> Vec<RoomInfo>

获取房间统计信息

Source

pub async fn offline_rooms_by_condition<F>( &self, condition: F, save_data: bool, ) -> Result<Vec<String>>
where F: Fn(&RoomInfo) -> bool,

根据条件下线房间 例如:下线空闲时间超过指定时间的房间、下线没有客户端的房间等

Source

pub async fn offline_empty_rooms(&self, save_data: bool) -> Result<Vec<String>>

下线空房间(没有客户端连接的房间)

Source

pub async fn offline_inactive_rooms( &self, inactive_duration: Duration, save_data: bool, ) -> Result<Vec<String>>

下线长时间未活动的房间

Source

pub async fn shutdown(&self, save_all_data: bool) -> Result<()>

服务器完全关闭 - 下线所有房间

Source

pub async fn start(self)

启动 WebSocket 服务器

Source

pub fn sync_service(&self) -> &Arc<SyncService>

获取 SyncService 的引用,用于外部操作

Trait Implementations§

Source§

impl Clone for CollaborationServer

Source§

fn clone(&self) -> CollaborationServer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,