             })
             rerender_editor_from_queue()
 
+            # logic to occaionally send all content to server
+            # server will save on non-null value.
+
             socket.emit 'change',
                 change: changeObj,
                 all_content: editor.doc.getValue(),


    # Init values for changes

    startcontent = editor.doc.getValue()
    queue = []
    has_remote_edits = false
    sort_by_time = (a,b) ->
        if a.time < b.time



    socket.on 'remote_change', (change) ->
        has_remote_edits = true

        window.clearTimeout(remote_edit_timeout)
        remote_edit_timeout = window.setTimeout ->
            has_remote_edits = false
            startcontent = editor.doc.getValue()
            queue = []

        , maximum_latency

        queue.push({
            time: change.time,
            change: change.change
        })
        # rerender_editor_from_queue()
        history = editor.doc.getHistory()
        editor.doc.replaceRange(
            change.change.text, 
            change.change.from, 
            change.change.to, 
            'remote'
        )
        editor.doc.setHistory(history)

        # var cursor_coords = editor.cursorCoords(changeObj.to)
        # console.log(cursor_coords)
