             })
             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(),



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

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


    # Init values for changes

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