Real Time Event Dispatcher Pushing symfony events in real time to your clients
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“
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 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
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 Request JSON data Process Event Response on long-polling AJAX request Event bubbling through Browser Tab Browser Tab
Real-Time?? Really really? Yes, really really! * Because it is not Polling! Data is being „pushed“! Real Time Event Dispatcher * Conditions apply: Network latency, Server load, …
Polling? „ Polling is just reverse Spam“ 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
AJAX Long Polling POST /longpoll HTTP/1.1 .oO(ZZZZZZ) - Wait for data Or close, send data, and wait again Real Time Event Dispatcher Server Client 25s 25s POST Data Rx Data
Comet Servers APE (AJAX Push Engine, V2 coming, OSS) node.js  StreamHub (Community Edition available) Meteor (OSS) … Share your alternatives later? Real Time Event Dispatcher BTW, your Apache would of course instantly go down...
What is APE? www.ape-project.org C, optimised for long-polling Provides Server and Client JS Framework Channels to listen on Internally calls it „pipes“ – public and private (=sent to a channel or send to a „user“) Real Time Event Dispatcher http://www.xosofox.de/2010/03/playing-with-my-new-pet-ape/
... Some APE specifics Functionality „by itself“ quite bare Comes with some modules Add Server Side JS getPipeByUser? You need to define your own user session handling to „send to username“ Real Time Event Dispatcher http://www.xosofox.de/2010/10/ape-user-handling/
Enough! Gimmi code! Sf Event Dispatcher Real Time Event Dispatcher Dennis Benkert @denderello #sfLive2010 http://www.slideshare.net/denderello/symfony-live-2010-using-symfony-events-to-create-clean-class-interfaces
... More code Custom Event Handler Real Time Event Dispatcher Event Payload Channel Define your payload here!
... Even more Code Call to inline push on APE JSON based Need special commands on the server Real Time Event Dispatcher
…  Even more Code Real Time Event Dispatcher Event Payload Channel
Server Side JS Example of event dispatching Real Time Event Dispatcher Event Payload Channel
Gimmi JS Client Side APE_JSF EventHandler Real Time Event Dispatcher
Gimmi JS Do something Change favicon Add/Remove Elements Redraw Canvas Add to Log Real Time Event Dispatcher
Some things to consider Auth*ation User-Handling, concurrent tabs? Refresh < -- > Session resume Channels Public? Page-Design Reloads? => Reconnect => new session Persistent overlay <div> with iframe? Real Time Event Dispatcher
APE Alternatives? node.js (bare) socket.io (tries to find „best“ method, websockets, AJAX, Flash, ...) RabbitMQ? JSONRPC Better ask @old_sound about that RabbitMQ and APE could work together Real Time Event Dispatcher
Psst... Annoying stuff APE APE Protocol takes some time to grasp Little/confusing docs Performance General: Browser parallel limits Same origin (APE‘s workaround is *.domain.com) Iframe User/session handling Real Time Event Dispatcher
Recap Nice interaction between sf backend server, Comet server and Client Interesting, different techniques involved PHP Backend JS Server side JS Client side Just soo cool – as soon as it works ;-) Real Time Event Dispatcher
Further reading Ape-project.org Node.js RabbitMQ Real Time Event Dispatcher
There‘s one more thing Questions? Share your experience If you like it, keep nagging @KaroDidi to release sfRealTimeEventDispatcherPlugin Real Time Event Dispatcher ... And please give http://tmeet.de/sflive a try

Real Time Event Dispatcher

  • 1.
    Real Time EventDispatcher Pushing symfony events in real time to your clients
  • 2.
    Imagine Games RememberGoogle 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.
    IT‘S JUST SOOOOCOOL!!! You click somewhere and immediately see a response somewhere else... Real Time Event Dispatcher
  • 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.
    The Big BictureSome PHP Some data transport Some JS Real Time Event Dispatcher sfBackend APE
  • 6.
    Real Time EventDispatcher 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.
    Real-Time?? Really really?Yes, really really! * Because it is not Polling! Data is being „pushed“! Real Time Event Dispatcher * Conditions apply: Network latency, Server load, …
  • 8.
    Polling? „ Pollingis just reverse Spam“ 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.
    AJAX Long PollingPOST /longpoll HTTP/1.1 .oO(ZZZZZZ) - Wait for data Or close, send data, and wait again Real Time Event Dispatcher Server Client 25s 25s POST Data Rx Data
  • 10.
    Comet Servers APE(AJAX Push Engine, V2 coming, OSS) node.js StreamHub (Community Edition available) Meteor (OSS) … Share your alternatives later? Real Time Event Dispatcher BTW, your Apache would of course instantly go down...
  • 11.
    What is APE?www.ape-project.org C, optimised for long-polling Provides Server and Client JS Framework Channels to listen on Internally calls it „pipes“ – public and private (=sent to a channel or send to a „user“) Real Time Event Dispatcher http://www.xosofox.de/2010/03/playing-with-my-new-pet-ape/
  • 12.
    ... Some APEspecifics Functionality „by itself“ quite bare Comes with some modules Add Server Side JS getPipeByUser? You need to define your own user session handling to „send to username“ Real Time Event Dispatcher http://www.xosofox.de/2010/10/ape-user-handling/
  • 13.
    Enough! Gimmi code!Sf Event Dispatcher 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.
    ... More codeCustom Event Handler Real Time Event Dispatcher Event Payload Channel Define your payload here!
  • 15.
    ... Even moreCode Call to inline push on APE JSON based Need special commands on the server Real Time Event Dispatcher
  • 16.
    … Evenmore Code Real Time Event Dispatcher Event Payload Channel
  • 17.
    Server Side JSExample of event dispatching Real Time Event Dispatcher Event Payload Channel
  • 18.
    Gimmi JS ClientSide APE_JSF EventHandler Real Time Event Dispatcher
  • 19.
    Gimmi JS Dosomething Change favicon Add/Remove Elements Redraw Canvas Add to Log Real Time Event Dispatcher
  • 20.
    Some things toconsider Auth*ation User-Handling, concurrent tabs? Refresh < -- > Session resume Channels Public? Page-Design Reloads? => Reconnect => new session Persistent overlay <div> with iframe? Real Time Event Dispatcher
  • 21.
    APE Alternatives? node.js(bare) socket.io (tries to find „best“ method, websockets, AJAX, Flash, ...) RabbitMQ? JSONRPC Better ask @old_sound about that RabbitMQ and APE could work together Real Time Event Dispatcher
  • 22.
    Psst... Annoying stuffAPE APE Protocol takes some time to grasp Little/confusing docs Performance General: Browser parallel limits Same origin (APE‘s workaround is *.domain.com) Iframe User/session handling Real Time Event Dispatcher
  • 23.
    Recap Nice interactionbetween sf backend server, Comet server and Client Interesting, different techniques involved PHP Backend JS Server side JS Client side Just soo cool – as soon as it works ;-) Real Time Event Dispatcher
  • 24.
    Further reading Ape-project.orgNode.js RabbitMQ Real Time Event Dispatcher
  • 25.
    There‘s one morething Questions? Share your experience If you like it, keep nagging @KaroDidi to release sfRealTimeEventDispatcherPlugin Real Time Event Dispatcher ... And please give http://tmeet.de/sflive a try