Skip to content

Commit 490c304

Browse files
committed
Add echo endpoint to server for sync check
1 parent ecdb57b commit 490c304

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

crates/y-sweet-core/src/doc_connection.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ type Callback = Arc<dyn Fn(&[u8]) + 'static>;
2222
#[cfg(feature = "sync")]
2323
type Callback = Arc<dyn Fn(&[u8]) + 'static + Send + Sync>;
2424

25+
const SYNC_STATUS_MESSAGE: u8 = 102;
26+
2527
pub struct DocConnection {
2628
awareness: Arc<RwLock<Awareness>>,
2729
#[allow(unused)] // acts as RAII guard
@@ -184,6 +186,10 @@ impl DocConnection {
184186
let mut awareness = a.write().unwrap();
185187
protocol.handle_awareness_update(&mut awareness, update)
186188
}
189+
Message::Custom(SYNC_STATUS_MESSAGE, data) => {
190+
// Respond to the client with the same payload it sent.
191+
Ok(Some(Message::Custom(SYNC_STATUS_MESSAGE, data)))
192+
}
187193
Message::Custom(tag, data) => {
188194
let mut awareness = a.write().unwrap();
189195
protocol.missing_handle(&mut awareness, tag, data)

0 commit comments

Comments
 (0)