ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.29k stars 125 forks source link

v3 - WIP #772

Open janthurau opened 9 months ago

janthurau commented 9 months ago

goals:

solirpa commented 9 months ago

Consider using the api Y.diffUpdate, we don't need to load ydoc into memory.

Here is the simulation syncstep1 and syncstep2 code:

if messageYjsSyncStep1
    cli_sv = decode(cli_msg)
    srv_state = load(name)

    diff = Y.diffUpdate(srv_state, cli_sv);
    send(writeSyncStep2(diff))

    srv_sv = Y.encodeStateVectorFromUpdate(srv_state)
    send(writeFirstSyncStep(srv_sv))

else if messageYjsSyncStep2
    update = decode(msg)
    srv.persist(update)

......