Basically on keyup I ship the whole contents of the editor and the cursor position to firebase. I'm also keeping track of all the active connections to a scratchpad document so I know who is typing. Anytime the code changes on the server, it triggers a callback function on each client that will update the contents of the textarea. If someone else is typing, the document is locked so only 1 person can type at a time. This way I can avoid all the potential merge conflicting type things that can happen.
Not sure what server architecture you're using, but in Node.js there is a pretty amazing package that integrates with ACE called ShareJS (http://sharejs.org/).
Have you experimented with synchronizing cursors at all?
Thanks! I'll have to read up on OT. Our backend is totally hosted by Firebase, other than a simple Sinatra app that generates the unique IDs.
When you say synchronizing cursors, do you mean having multiple cursors (google docs style) or having a single cursor be in the same position for all clients? We are doing the latter, and I wasn't aware it was possible to do the former with ace but I would love to do it if I can
Seems that I can't reply to the child of my sibling comment so I'm replying here.
ACE is quite ridiculously powerful. On its primary implementation (http://c9.io), it supports multiple cursors with concurrent editing.
I've been able to use ShareJS to get concurrent editing working (see: http://plnkr.co/edit/?p=preview&s=HN4933608) but haven't had a chance to display visual cursors for all simultaneous users. I was thinking that I could get that working using Firebase.
Hi, I'm one of the Firebase engineers working on keeping clients connected.
We use a mix of different methods to maintain a connection. We normally start with our custom long polling implementation and move to websockets when they are available. We do not currently make use of any flash sockets.