Real Time Event Dispatcher <ul><li>Pushing symfony events </li></ul><ul><li>in real time </li></ul><ul><li>to your clients...
Imagine Games Remember Google Wave? No? Anyone??? Read/Delete a message, all favicons change Your turn? Instant notificati...
IT‘S JUST SOOOO COOL!!! You click somewhere and immediately see a response somewhere else... Real Time Event Dispatcher
@KaroDidi 1 wife, 2 kids, 3 monitors 34 years Day-Job: Working  on Excel/Access VBA Applications :-/  True heart belongs t...
The Big Bicture Some PHP Some data transport Some JS Real Time Event Dispatcher sfBackend APE
Real Time Event Dispatcher lib/model APE Custom Event Handler sfEventHandler Browser Browser Browser Throw Event HTTP Requ...
Real-Time?? Really really? <ul><li>Yes, really really! * </li></ul><ul><li>Because it is not Polling! Data is being „pushe...
Polling? <ul><li>„ Polling is just reverse Spam“ </li></ul>Real Time Event Dispatcher Alexis Richardson http://www.rabbitm...
AJAX Long Polling <ul><li>POST /longpoll HTTP/1.1 </li></ul><ul><li>.oO(ZZZZZZ) - Wait for data </li></ul><ul><li>Or close...
Comet Servers <ul><li>APE (AJAX Push Engine, V2 coming, OSS) </li></ul><ul><li>node.js  </li></ul><ul><li>StreamHub (Commu...
What is APE? <ul><li>www.ape-project.org </li></ul><ul><li>C, optimised for long-polling </li></ul><ul><li>Provides Server...
... Some APE specifics <ul><li>Functionality „by itself“ quite bare </li></ul><ul><li>Comes with some modules </li></ul><u...
Enough! Gimmi code! <ul><li>Sf Event Dispatcher </li></ul>Real Time Event Dispatcher Dennis Benkert @denderello #sfLive201...
... More code <ul><li>Custom Event Handler </li></ul>Real Time Event Dispatcher Event Payload Channel Define your payload ...
... Even more Code <ul><li>Call to inline push on APE </li></ul><ul><li>JSON based </li></ul><ul><li>Need special commands...
…  Even more Code Real Time Event Dispatcher Event Payload Channel
Server Side JS <ul><li>Example of event dispatching </li></ul>Real Time Event Dispatcher Event Payload Channel
Gimmi JS <ul><li>Client Side APE_JSF EventHandler </li></ul>Real Time Event Dispatcher
Gimmi JS <ul><li>Do something </li></ul><ul><ul><li>Change favicon </li></ul></ul><ul><ul><li>Add/Remove Elements </li></u...
Some things to consider <ul><li>Auth*ation </li></ul><ul><li>User-Handling, concurrent tabs? </li></ul><ul><li>Refresh < -...
APE Alternatives? <ul><li>node.js (bare) </li></ul><ul><ul><li>socket.io (tries to find „best“ method, websockets, AJAX, F...
Psst... Annoying stuff <ul><li>APE </li></ul><ul><ul><li>APE Protocol takes some time to grasp </li></ul></ul><ul><ul><li>...
Recap <ul><li>Nice interaction between sf backend server, Comet server and Client </li></ul><ul><li>Interesting, different...
Further reading <ul><li>Ape-project.org </li></ul><ul><li>Node.js </li></ul><ul><li>RabbitMQ </li></ul>Real Time Event Dis...
There‘s one more thing <ul><li>Questions? </li></ul><ul><li>Share your experience </li></ul><ul><li>If you like it, keep n...
Upcoming SlideShare
Loading in...5
×

Real Time Event Dispatcher

5,471

Published on

Pushing symfony events in real time to your clients
This talk, held at the symfony live Paris unconference, gives an overview about how events thrown in symfony can be dispatched in real time to web clients. It describes the architecture of the solution and provides examples using the open source comet server APE

Published in: Technology, Business
0 Comments
14 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,471
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
82
Comments
0
Likes
14
Embeds 0
No embeds

No notes for slide

Real Time Event Dispatcher

  1. 1. Real Time Event Dispatcher <ul><li>Pushing symfony events </li></ul><ul><li>in real time </li></ul><ul><li>to your clients </li></ul>
  2. 2. Imagine Games Remember Google Wave? No? Anyone??? Read/Delete a message, all favicons change Your turn? Instant notification GMail Like „tail –f /var/log/my.log >some.browsers“
  3. 3. IT‘S JUST SOOOO COOL!!! You click somewhere and immediately see a response somewhere else... Real Time Event Dispatcher
  4. 4. @KaroDidi 1 wife, 2 kids, 3 monitors 34 years Day-Job: Working on Excel/Access VBA Applications :-/ True heart belongs to Web and PHP since >10 Years Own company/Freelancer www.smartpixelmedia.de Real-Life? Ah, right... Mountainbike Model plane/heli Peter Dietrich Real Time Event Dispatcher Hobbies: www.karopapier.de www.xosofox.de www.managerator.de www.tmeet.de www.timini.de www.beididi.de www.jobeet.de / www.symfony2.de www.d1d.li
  5. 5. The Big Bicture Some PHP Some data transport Some JS Real Time Event Dispatcher sfBackend APE
  6. 6. Real Time Event Dispatcher lib/model APE Custom Event Handler sfEventHandler Browser Browser Browser Throw Event HTTP Request JSON data Process Event Response on long-polling AJAX request Event bubbling through Browser Tab Browser Tab
  7. 7. Real-Time?? Really really? <ul><li>Yes, really really! * </li></ul><ul><li>Because it is not Polling! Data is being „pushed“! </li></ul>Real Time Event Dispatcher * Conditions apply: Network latency, Server load, …
  8. 8. Polling? <ul><li>„ Polling is just reverse Spam“ </li></ul>Real Time Event Dispatcher Alexis Richardson http://www.rabbitmq.com/resources/RabbitMQ_Oxford_Geek_Night.pdf (Slide 23) http://www.ape-project.org/comics/1/Chapter-I-common-let-s-push.html
  9. 9. AJAX Long Polling <ul><li>POST /longpoll HTTP/1.1 </li></ul><ul><li>.oO(ZZZZZZ) - Wait for data </li></ul><ul><li>Or close, send data, and wait </li></ul><ul><li>again </li></ul>Real Time Event Dispatcher Server Client 25s 25s POST Data Rx Data
  10. 10. Comet Servers <ul><li>APE (AJAX Push Engine, V2 coming, OSS) </li></ul><ul><li>node.js </li></ul><ul><li>StreamHub (Community Edition available) </li></ul><ul><li>Meteor (OSS) </li></ul><ul><li>… </li></ul><ul><li>Share your alternatives later? </li></ul>Real Time Event Dispatcher BTW, your Apache would of course instantly go down...
  11. 11. What is APE? <ul><li>www.ape-project.org </li></ul><ul><li>C, optimised for long-polling </li></ul><ul><li>Provides Server and Client JS Framework </li></ul><ul><li>Channels to listen on </li></ul><ul><li>Internally calls it „pipes“ – public and private (=sent to a channel or send to a „user“) </li></ul>Real Time Event Dispatcher http://www.xosofox.de/2010/03/playing-with-my-new-pet-ape/
  12. 12. ... Some APE specifics <ul><li>Functionality „by itself“ quite bare </li></ul><ul><li>Comes with some modules </li></ul><ul><li>Add Server Side JS </li></ul><ul><li>getPipeByUser? </li></ul><ul><li>You need to define your own user session handling to „send to username“ </li></ul>Real Time Event Dispatcher http://www.xosofox.de/2010/10/ape-user-handling/
  13. 13. Enough! Gimmi code! <ul><li>Sf Event Dispatcher </li></ul>Real Time Event Dispatcher Dennis Benkert @denderello #sfLive2010 http://www.slideshare.net/denderello/symfony-live-2010-using-symfony-events-to-create-clean-class-interfaces
  14. 14. ... More code <ul><li>Custom Event Handler </li></ul>Real Time Event Dispatcher Event Payload Channel Define your payload here!
  15. 15. ... Even more Code <ul><li>Call to inline push on APE </li></ul><ul><li>JSON based </li></ul><ul><li>Need special commands on the server </li></ul>Real Time Event Dispatcher
  16. 16. … Even more Code Real Time Event Dispatcher Event Payload Channel
  17. 17. Server Side JS <ul><li>Example of event dispatching </li></ul>Real Time Event Dispatcher Event Payload Channel
  18. 18. Gimmi JS <ul><li>Client Side APE_JSF EventHandler </li></ul>Real Time Event Dispatcher
  19. 19. Gimmi JS <ul><li>Do something </li></ul><ul><ul><li>Change favicon </li></ul></ul><ul><ul><li>Add/Remove Elements </li></ul></ul><ul><ul><li>Redraw Canvas </li></ul></ul><ul><ul><li>Add to Log </li></ul></ul>Real Time Event Dispatcher
  20. 20. Some things to consider <ul><li>Auth*ation </li></ul><ul><li>User-Handling, concurrent tabs? </li></ul><ul><li>Refresh < -- > Session resume </li></ul><ul><li>Channels </li></ul><ul><li>Public? </li></ul><ul><li>Page-Design </li></ul><ul><ul><li>Reloads? => Reconnect => new session </li></ul></ul><ul><ul><li>Persistent overlay <div> with iframe? </li></ul></ul>Real Time Event Dispatcher
  21. 21. APE Alternatives? <ul><li>node.js (bare) </li></ul><ul><ul><li>socket.io (tries to find „best“ method, websockets, AJAX, Flash, ...) </li></ul></ul><ul><li>RabbitMQ? </li></ul><ul><ul><li>JSONRPC </li></ul></ul><ul><ul><li>Better ask @old_sound about that </li></ul></ul><ul><ul><li>RabbitMQ and APE could work together </li></ul></ul>Real Time Event Dispatcher
  22. 22. Psst... Annoying stuff <ul><li>APE </li></ul><ul><ul><li>APE Protocol takes some time to grasp </li></ul></ul><ul><ul><li>Little/confusing docs </li></ul></ul><ul><ul><li>Performance </li></ul></ul><ul><li>General: </li></ul><ul><ul><li>Browser parallel limits </li></ul></ul><ul><ul><li>Same origin (APE‘s workaround is *.domain.com) </li></ul></ul><ul><ul><li>Iframe </li></ul></ul><ul><ul><li>User/session handling </li></ul></ul>Real Time Event Dispatcher
  23. 23. Recap <ul><li>Nice interaction between sf backend server, Comet server and Client </li></ul><ul><li>Interesting, different techniques involved </li></ul><ul><ul><li>PHP Backend </li></ul></ul><ul><ul><li>JS Server side </li></ul></ul><ul><ul><li>JS Client side </li></ul></ul><ul><li>Just soo cool – as soon as it works ;-) </li></ul>Real Time Event Dispatcher
  24. 24. Further reading <ul><li>Ape-project.org </li></ul><ul><li>Node.js </li></ul><ul><li>RabbitMQ </li></ul>Real Time Event Dispatcher
  25. 25. There‘s one more thing <ul><li>Questions? </li></ul><ul><li>Share your experience </li></ul><ul><li>If you like it, keep nagging @KaroDidi to release sfRealTimeEventDispatcherPlugin </li></ul>Real Time Event Dispatcher ... And please give http://tmeet.de/sflive a try
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×