4 ms·
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 scratc
by nbashaw 14y ago
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.
I'm not sure what an OT engine is. What is that?
- gbadman 14y agoSeems 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 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 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.
- gbadman 14y agoOT (See: http://en.wikipedia.org/wiki/Operational_transformation http://en.wikipedia.org/wiki/Operational_transformation) is one of the technology solutions to the problem that you've solved through a locking mechanism. 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/ http://sharejs.org/). Have you experimented with synchronizing cursors at all?
- nbashaw 14y agoThanks! 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
- michaelbuckbee 14y agoDo you know what/how Firebase is doing the realtime updates? Websockets with fallback to flash?
- gsoltis 14y agoHi, 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.
- daemon13 14y agoIs Firebase open source? It states so on the sites/GH pages, but could not find pointers to repo [after 2 circle through 5 different pages poiting to each other].
- nbashaw 14y agoI believe that's it but I'm not sure. I've emailed the firebase founder and he might be able to chime in here