Sinatra Drinks Coffee: Server-Sent Events w/ Sinatra, Thin, and CoffeeScript

Through the pursuit of experimenting with real-time digital collaboration, I’ve been exploring server-sent events (SSE) with a Ruby web development DSL called Sinatra, backed by a lightweight web server called Thin. Check out a live demo at sinatra-drinks-coffee.herokuapp.com (open it in multiple browser windows to see the full effect). Then, explore the code on github. It’s very straight-forward, but feel free to ask questions in the comments.

November 1964 --- American singer and actor Frank Sinatra. --- Image by © John Bryson/Sygma/Corbis

November 1964 — American singer and actor Frank Sinatra. — Image by © John Bryson/Sygma/Corbis

People are more likely to stay engaged in digital collaboration if they can observe each other’s actions in real-time. In order for people to observe each other’s actions, objects and their states must rapidly synchronize across all connected and authorized clients. This need has traditionally been a complicated problem given that the internet is stateless. The internet protocol (IP) was designed to treat data as independent pairs of requests and responses; not as continuous bi-directional streams. However, the perception of persistent connections between servers and clients are necessary for real-time collaboration.

Even more fun than twisting the original architecture of the internet is the need for reconciling conflicts that arise when more than one person changes a document’s state. If you have ever used Google Docs, you have used a web service that supports real-time collaboration using operational transformation control (integration) algorithms.

In spite of the challenges and limitations of real-time collaboration, I anticipate that people will expect these tools to support an ever-expanding range of activities in the next few years. Especially in engineering, design and architecture.

Here’s a good explanation of how Google reconciles conflicts in Google Docs: http://googledocs.blogspot.com/2010/09/whats-different-about-new-google-docs_22.html

Server-Sent Events Vs. Web Sockets
http://stackoverflow.com/questions/5195452/websockets-vs-server-sent-events-eventsource/5326159#5326159

Comprehensive Explanation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s