pub struct CollaborationServer { /* private fields */ }Expand description
YrsManager 的包装器,用于处理动态房间创建和广播组管理
Implementations§
Source§impl CollaborationServer
impl CollaborationServer
pub fn new(yrs_manager: Arc<YrsManager>, port: u16) -> Self
Sourcepub fn with_sync_service(
yrs_manager: Arc<YrsManager>,
sync_service: Arc<SyncService>,
port: u16,
) -> Self
pub fn with_sync_service( yrs_manager: Arc<YrsManager>, sync_service: Arc<SyncService>, port: u16, ) -> Self
使用现有的 SyncService 创建服务器
Sourcepub async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible>
pub async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible>
自定义错误处理器
Sourcepub async fn init_room_with_data(
&self,
room_id: &str,
tree: &Tree,
) -> Result<()>
pub async fn init_room_with_data( &self, room_id: &str, tree: &Tree, ) -> Result<()>
初始化房间,可选择性地使用现有的 Tree 数据进行同步 这是关键的初始化时机:在客户端连接前确保房间已经准备好
Sourcepub async fn offline_room(&self, room_id: &str, save_data: bool) -> Result<bool>
pub async fn offline_room(&self, room_id: &str, save_data: bool) -> Result<bool>
房间下线 - 优雅关闭房间
- 通知所有客户端房间即将关闭
- 等待客户端完成当前操作
- 保存数据(可选)
- 清理资源
Sourcepub async fn force_offline_room(&self, room_id: &str) -> Result<bool>
pub async fn force_offline_room(&self, room_id: &str) -> Result<bool>
强制房间下线 - 紧急情况使用
Sourcepub async fn offline_rooms(
&self,
room_ids: &[String],
save_data: bool,
) -> Result<Vec<(String, bool)>>
pub async fn offline_rooms( &self, room_ids: &[String], save_data: bool, ) -> Result<Vec<(String, bool)>>
批量下线房间
Sourcepub fn get_active_rooms(&self) -> Vec<String>
pub fn get_active_rooms(&self) -> Vec<String>
获取所有活跃房间列表
Sourcepub async fn get_rooms_stats(&self) -> Vec<RoomInfo>
pub async fn get_rooms_stats(&self) -> Vec<RoomInfo>
获取房间统计信息
Sourcepub async fn offline_rooms_by_condition<F>(
&self,
condition: F,
save_data: bool,
) -> Result<Vec<String>>
pub async fn offline_rooms_by_condition<F>( &self, condition: F, save_data: bool, ) -> Result<Vec<String>>
根据条件下线房间 例如:下线空闲时间超过指定时间的房间、下线没有客户端的房间等
Sourcepub async fn offline_empty_rooms(&self, save_data: bool) -> Result<Vec<String>>
pub async fn offline_empty_rooms(&self, save_data: bool) -> Result<Vec<String>>
下线空房间(没有客户端连接的房间)
Sourcepub async fn offline_inactive_rooms(
&self,
inactive_duration: Duration,
save_data: bool,
) -> Result<Vec<String>>
pub async fn offline_inactive_rooms( &self, inactive_duration: Duration, save_data: bool, ) -> Result<Vec<String>>
下线长时间未活动的房间
Sourcepub fn sync_service(&self) -> &Arc<SyncService>
pub fn sync_service(&self) -> &Arc<SyncService>
获取 SyncService 的引用,用于外部操作
Trait Implementations§
Source§impl Clone for CollaborationServer
impl Clone for CollaborationServer
Source§fn clone(&self) -> CollaborationServer
fn clone(&self) -> CollaborationServer
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CollaborationServer
impl !RefUnwindSafe for CollaborationServer
impl Send for CollaborationServer
impl Sync for CollaborationServer
impl Unpin for CollaborationServer
impl !UnwindSafe for CollaborationServer
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> 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> 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