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


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?


  • if data only needs to be streamed to the client
  • using plain HTTP, don't need a special protocol
  • automatic reconnection and event IDs



REAL TIME RUBY


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

  • sinatra-websocket gem


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



THE RACK INTERFACE

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

FOLDER STRUCTURE



HTTP ROUTING



HTTP CONTROLLERS


 

WEBSOCKET HANDLERS






NOODLES WIKI AND SOURCE CODE:

https://github.com/DamirSvrtan/noodles


SAMPLE APPLICATION SOURCE CODE:

https://github.com/DamirSvrtan/noodle-app

Ruby Framework For Bidirectional Communication with a Web Server

By Damir Svrtan

Ruby Framework For Bidirectional Communication with a Web Server

  • 1,152