This can be okay, or even useful, since it provides a detailed history This implementation endlessly accumulates updates for every single The authority after such an event.) Dropping Old Updates If confirming localĬhanges only happened on push, it would be hard to resynchronize with Request successfully arrives at the authority, but the network failsīefore the response comes back to the peer. Remote updates is that we want to handle the case where the push (The reason local updates are confirmed through the same mechanism as Updates you pushed when the push comes back successful. Will break stuff), for example by making pull and push mutuallyĮxclusive, you could immediately use receiveUpdates on the local If your control over the pull process is precise enough that you canĮnsure that you're not going to confirm the same updates twice (which Make sure its own updates are confirmed, it relies entirely on them The view plugin above ignores the return value from pushUpdates. The state kept by the authority is just an array of updates (holding aĬhange set and a client ID), and a currentĭocument. World, it'll typically be a server program communicating with peersĮrror handling will be omitted throughout the example to keep things Still allowing everything to run inside the browser. To serialize data that goes over the communication channel, while Helps simulate the asynchronous nature of communication, and the need The communication between the peers and the authority (which can get aīit more subtle due to the nature of networked/asynchronous systems). Must implement the authority (which can be very simple) and wire up The more tricky logic that a peer must apply is implemented in package, but to set up a collaborative system you Receives the conflicting changes, and try again after integrating Otherwise, it rejects them, and the peer must wait until it If that version matches the server's version, the serverĪccepts the changes and adds them to its history. To send them to the authority, along with its current synchronized Whenever there are unconfirmed local changes, the peer should try The peer's document version is moved forward. Updated local changes can be submitted to the server as if they The unconfirmed local ones, and vice versa, so that the remoteĬhanges can be applied to the peer's current document, and the Transformation is used to transpose the remote changes across If there are unconfirmed changes present, operational Remote changes are applied to the local editor state. If some of those changes are the peer's own changes, thoseĬhanges are removed from the list of unconfirmed changes. History they have synchronized with, and which local (unconfirmed)Īll peers set up some way to receive new changes from the Individual editors (peers) track which version of the authority's There is a central system (authority) that builds up a history of See for exampleĬollaborative systems implemented with package work like this: (It is also possible to wire up different collaborative editingĪlgorithms to CodeMirror. For more theoretical information, see this blog This example describes the practical information you need to With a central authority (server) that assigns a definite order to theĬhanges. Is possible for people to make changes at the same time, which have toīe reconciled in some way when synchronizing everybody up again.ĬodeMirror comes with utilities for collaborative editing based on The main difficulty with this style of editing is handling ofĬonflicting edits-since network communication isn't instantaneous, it
0 Comments
Leave a Reply. |