 
                 if @_last_sync?
                     # applying missed patches to the new upstream version that we just got from the hub.
-                    @live(diffsync.dmp.patch_apply(patch, @live())[0])
+                    @_apply_patch_to_live(patch)
                 else
                     # This initialiation is the first sync.
                     @_last_sync   = resp.content

            @dsync_client.live = s
        else
            @dsync_client?.live

    # "sync(cb)": keep trying to synchronize until success; then do cb()
    # _sync(cb) -- try once to sync; on any error cb(err).

                cb?()

    _add_listeners: () =>
        salvus_client.on 'codemirror_diffsync_ready', @__diffsync_ready
        #salvus_client.on 'codemirror_bcast', @__receive_broadcast

    _remove_listeners: () =>
        salvus_client.removeListener 'codemirror_diffsync_ready', @__diffsync_ready
        #salvus_client.removeListener 'codemirror_bcast', @__receive_broadcast

    __diffsync_ready: (mesg) =>
        if mesg.session_uuid == @session_uuid
            @sync()

    #__receive_broadcast: (mesg) =>
    #    if mesg.session_uuid != @session_uuid
    #        @_receive_broadcast?(mesg)   # define in derived class

    # @live(): the current live version of this document as a string, or
    # @live(s): set the live version
