Your SlideShare is downloading. ×
0
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Ruby EventMachine + em-WebSocket
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ruby EventMachine + em-WebSocket

3,255

Published on

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

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,255
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
31
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ruby EventMachine Y un pequeño ejemplo usando em-websockets @CarlosForero
  • 2. Concurrencia
  • 3. Concurrencia usando hilos (Threads)
  • 4. 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
  • 5. Concurrencia usando el Patrón Reactor (Reactor Pattern)
  • 6. Reactor Pattern vs Multithreading Apache Thread Based ServerEvent Driven Based Server
  • 7. Reactor Pattern vs Multithreading
  • 8. Reactor Pattern vs Multithreading
  • 9. Concurrencia usando el Patrón Reactor (Reactor Pattern)
  • 10. Reactor Pattern
  • 11. Ruby EventMachine require 'eventmachine' EM.run do EM.add_timer(5) do puts "Extremadamente simple... adios!" EM.stop end end
  • 12. Ruby EventMachine require 'eventmachine' EM.run do EM.add_timer(7) do puts "Listo" EM.stop_event_loop end EM.add_periodic_timer(1) do puts "Esperando ... " end end
  • 13. EventMachine::Connection
  • 14. EventMachine::Connection require 'eventmachine' class EchoHandler < EM::Connection def receive_data(data) send_data(data) end end EM.run do EM.start_server("127.0.0.1", 10000, EchoHandler) end
  • 15. EventMachine::Connection Events post_init connection_completed receive_data(data) unbind Methods close_connection close_connection_after_writing
  • 16. Un solo hilo para el reactor
  • 17. EM#defer require 'eventmachine' require 'thread' EM.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}" end end
  • 18. EM#defer
  • 19. EM#defer con Callback require 'eventmachine' EM.run do operation = proc do 5 + 5 end callback = proc do |count| puts "5 + 5 == #{count}" EM.stop end EM.defer(operation, callback) end
  • 20. EM#defer con Callback
  • 21. EM#defer con Callback Un ejemplo más práctico con... gem install eventmachine_httpserver
  • 22. Ahora si... gem install em-websockets
  • 23. Pero antes un repaso...
  • 24. Arquitectura HTTP
  • 25. Ajax (Pull)
  • 26. Comet (Push)
  • 27. HTML 5 WebSockets
  • 28. HTML 5 WebSockets
  • 29. WebSockets Events
  • 30. Chat Server con em-websockets :-)
  • 31. Esta presentación se hizo con Si la quieres hazme follow y solicítamela... Gracias por su atención @CarlosForero

×