WEBSOCKETS
  WITH
   RUBY



 by Stoyan Zhekov
CURRENT WEB
     ( HTTP )

Broken!
CURRENT WEB (HTTP)

       Request
      Response
        Close
Mailman
Real Time

Bidirectional

 Full Duplex
SERVER TO SERVER

  PubSubHubBub

      XMPP
SERVER TO BROWSER

      Polling
      Long Polling
      Streaming
PUSH!
PUSH TO BROWSER

   Flash Socket
   XMPP (BOSH)
   WebSockets
“Comet is dead
   long live
 websockets”
“Comet is dead
   long live
 websockets”
-- Joe Armstrong
THEORY
http://www.websockets.org/


WEBSOCKETS
“WebSockets is a technology
providing for bi-directional,
full-duplex communications
channels, over a single Transmission
Control Protocol (TCP) socket,
designed to be implemented in
web browsers and web servers.”

                          --wikipedia
http://dev.w3.org/html5/websockets/



        http://bit.ly/9ioTAl
BROWSERS
•Chrome           4.0+
• WebKit    Nightly Builds

• Firefox   4.0 (Nov 2010)?
EMULATION




http://github.com/gimite/web-socket-js
WS://
WSS://
HANDSHAKE
DATA FRAME


0x00”...UTF-8...”xFF
SIMPLE
IMPLEMENTATION
Not
Easy
SECURITY
PERFORMANCE
COST
HELLO
WORLD
WHAT
 YOU
WANT?
WHAT YOU WANT?

• Chat

• Stocks

• Games

• Real   Time Notifications
GAMES




http://code.google.com/p/quake2-gwt-port/
REAL TIME NOTIFY




http://hummingbirdstats.com/
http://pusherapp.com/
EM-WEBSOCKET
http://github.com/igrigorik/em-websocket
http://rainbows.rubyforge.org/sunshowers/
http://heroku.com/

http://mongohq.com/

Websockets with ruby