Ruby Framework For Bidirectional Communication with a Web Server
Author: Damir Svrtan
Mentor: Prof. Sinisa Srbljic
SECTIONS:
1. Real Time Web Communication
2. Real Time Ruby
3. The Rack Interface
4. Building a Ruby Web Framework
5. The Future
WHAT IS Real Time Web COMMUNICATION?
AJAX & POLLING TECHNIQUES
LONG POLLING
SHORT POLLING
HTML 5
SERVER SENT EVENTS &
WEBSOCKETS
SERVER SENT EVENTS(SSE)
WEBSOCKETS
WHY USE SSE OVER WEBSOCKETS?
- data only needs to be streamed to the client
- using plain HTTP, don't need a special protocol
- automatic reconnection
EVENTMACHINE
Ruby library for building asynchronous, event driven applications
EVENTMACHINE LOOP
FAYE
- publish-subscribe messaging system
- most used real time library in Ruby
- client and server side libraries in Ruby and Node.js
Ruby on RAILS
- Out of box SSE via ActionController::Live
- WebSockets via WebSocket-Rails
SINATRA
- built in streaming option
GOLIATH
- bare-metal asynchronous web server framework
- used for high traffic API's
- not a replacement for Rails or Sinatra
CRAMP
- asynchronous real-time web application framework
- async crossover between Rails and Sinatra
RACK REQUEST HASH
HELLO WORLD WITH RACK
run MyApp.new
require 'rack'
class MyApp
def call(env)
[200, {'Content-Type' => 'text/html'}, ['Hello World']]
end
end
EXPERIMENTAL REAL TIME MVC RUBY WEB FRAMEWORK
EXTERNAL ARCHITECTURE
OUT OF BOX WEBSOCKET AND
HTTP PROTOCOL SUPPORT
INTERNAL ARCHITECTURE
FUTURE OF REAL TIME RUBY?
- Lack of Rails/Sinatra core team efforts
- Waiting for the Rack 2.0 specification
NOODLES WIKI AND SOURCE CODE:
https://github.com/DamirSvrtan/noodles
SAMPLE APPLICATION SOURCE CODE:
https://github.com/DamirSvrtan/noodle-app