Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Ruby EventMachine + em-WebSocket

on

  • 3,829 views

Presentación de la charla "Ruby EventMachine + em-WebSocket", la cual fue expuesta en la reunión inaugural del Grupos de Usuarios Ruby de Venezuela - http://ruby.org.ve

Presentación de la charla "Ruby EventMachine + em-WebSocket", la cual fue expuesta en la reunión inaugural del Grupos de Usuarios Ruby de Venezuela - http://ruby.org.ve

Statistics

Views

Total Views
3,829
Views on SlideShare
3,784
Embed Views
45

Actions

Likes
3
Downloads
30
Comments
0

2 Embeds 45

http://edgar.tumblr.com 32
http://flavors.me 13

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Ruby EventMachine + em-WebSocket Ruby EventMachine + em-WebSocket Presentation Transcript

  • Ruby EventMachineY un pequeño ejemplo usando em-websockets @CarlosForero
  • Concurrencia
  • Concurrencia usando hilos (Threads)
  • Concurrencia usando hilos (Threads) Cada uno tiene su propio Stack Uso de semáforos de sistema operativo Baja el desempeño cuando aumenta el número de conexiones
  • Concurrencia usando el Patrón Reactor (Reactor Pattern)
  • Reactor Pattern vs Multithreading ApacheEvent Driven Based Server Thread Based Server
  • Reactor Pattern vs Multithreading
  • Reactor Pattern vs Multithreading
  • Concurrencia usando el Patrón Reactor (Reactor Pattern)
  • Reactor Pattern
  • Ruby EventMachinerequire eventmachineEM.run do EM.add_timer(5) do puts "Extremadamente simple... adios!" EM.stop endend
  • Ruby EventMachinerequire eventmachineEM.run do EM.add_timer(7) do puts "Listo" EM.stop_event_loop end EM.add_periodic_timer(1) do puts "Esperando ... " endend
  • EventMachine::Connection
  • EventMachine::Connectionrequire eventmachineclass EchoHandler < EM::Connection def receive_data(data) send_data(data) endendEM.run do EM.start_server("127.0.0.1", 10000, EchoHandler)end
  • EventMachine::Connection Events post_init connection_completed receive_data(data) unbind Methods close_connectionclose_connection_after_writing
  • Un solo hilo para el reactor
  • EM#deferrequire eventmachinerequire threadEM.run do EM.add_timer(1) do puts "Ejecución de hilo principal => #{Thread.current}" EM.stop_event_loop end EM.defer do puts "Ejecución en segundo hilo => #{Thread.current}" endend
  • EM#defer
  • EM#defer con Callbackrequire eventmachineEM.run do operation = proc do 5 + 5 end callback = proc do |count| puts "5 + 5 == #{count}" EM.stop end EM.defer(operation, callback)end
  • EM#defer con Callback
  • EM#defer con Callback Un ejemplo más práctico con...gem install eventmachine_httpserver
  • Ahora si...gem install em-websockets
  • Pero antes un repaso...
  • Arquitectura HTTP
  • Ajax (Pull)
  • Comet (Push)
  • HTML 5 WebSockets
  • HTML 5 WebSockets
  • WebSockets Events
  • Chat Server con em-websockets :-)
  • Esta presentación se hizo conSi la quieres hazme followy solicítamela... @CarlosForeroGracias por su atención