typeintandem / tandem

Typing in Tandem. Decentralized, cross-editor, collaborative text-editing!
Apache License 2.0
698 stars 20 forks source link

Request and wait for permission before applying remote operations #51

Closed geoffxy closed 6 years ago

geoffxy commented 6 years ago

Now when the agent receives remote changes, it will queue them and send the plugin a WriteRequest message. The agent will only send this once for each batch of messages (we can change this later if it becomes an issue, but it will complicate the plugin logic a bit as well).

The plugin, upon receiving a WriteRequest message, should respond with a WriteRequestAck when able. Sending the ack message to the agent indicates that it is safe to apply all pending remote operations. So before sending it, the plugin should disallow (ideally queue, but not apply) changes to the buffer from the local user.

The agent will then reply with an ApplyText message that will contain text patches to apply (or no patches at all). Upon receiving this message the plugin can allow local edits to the buffer again.