Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Realtime Web with PocketIO    Ynon Perek    Tel Aviv Perl MongersSaturday, November 24, 12
Whoami    ✤    Ynon Perek    ✤    ynonperek.com    ✤    me@ynonperek.comSaturday, November 24, 12
Agenda    ✤    What’s wrong with HTTP    ✤    Real Time Web - Concepts    ✤    PocketIO Coding DemosSaturday, November 24,...
What is wrong with HTTP ?                            GET page                            Here It IsSaturday, November 24, 12
Let’s try a Live ChatSaturday, November 24, 12
HTTP Live Chat    ✤    All communication is mediated by server using HTTP                              Tell Laura I Love H...
HTTP Live Chat    ✤    But the server can only reply ...                                        Ok, got itSaturday, Novemb...
HTTP Live Chat    ✤    Waiting...Saturday, November 24, 12
HTTP Live Chat    ✤    Meantime, on Laura’s side                                 Do I have any                            ...
A second laterSaturday, November 24, 12
HTTP Live Chat                            Do I have any new                               messages ?                      ...
A second laterSaturday, November 24, 12
HTTP Live Chat                            Do I have any new                               messages ?                      ...
A second laterSaturday, November 24, 12
HTTP Live Chat                            Do I have any new                               messages ?                      ...
HTTP Live Chat Dark Side    ✤    Server is busy picking up requests    ✤    Clients are busy polling    ✤    Everyone lose...
Real Time    Web    ✤    Improved UX by allowing the         server to notify a clientSaturday, November 24, 12
What’s Available    ✤    Plugins (usually flash) to open client/server sockets    ✤    Comet    ✤    Web Sockets (modern b...
Meet PocketIO    Perl implementation of Socket.IO written    by vtiSaturday, November 24, 12
The Good    ✤    Chooses the best available         transport layer    ✤    Manages active connections         and reconne...
Coding TimeSaturday, November 24, 12
What You Need    ✤    Use Twiggy (or fliggy)    ✤    Use Plack::BuilderSaturday, November 24, 12
What You Need    ✤    /socket.io/socket.io.js should point to the client-side library               mount /socket.io/socke...
What You Need    ✤    /socket.io should return a new PocketIO object             mount /socket.io => PocketIO->new(       ...
PocketIO::Run    ✤    Demo 1: Echo ServerSaturday, November 24, 12
PocketIO Broadcasts    ✤    notify all except sender:         $sender->broadcast->emit(‘message’, ‘text’);    ✤    notify ...
PocketIO Broadcasts    ✤    Demo2: Shared Echo (wall)    ✤    Let’s turn our wall to multi-user wallSaturday, November 24,...
PocketIO Sharing Data    ✤    Use an external data store (DB, Redis)    ✤    Use PlackSaturday, November 24, 12
External Data Store                                   Shared Data                                      Store              ...
Plack    ✤    Create a shared variable in Plack::Builder (or a middleware)    ✤    Pass it to all apps    ✤    DemoSaturda...
PocketIO    Takeaways    ✤    Bring users closer together by         allowing smooth collaboration    ✤    Improve UX    ✤...
Thank You    ✤    Keynote’s available at:         http://www.slideshare.net/YnonPerek    ✤    Code available at:         h...
RealTime Web with PocketIO
RealTime Web with PocketIO
RealTime Web with PocketIO
RealTime Web with PocketIO
Upcoming SlideShare
Loading in …5
×

RealTime Web with PocketIO

1,907 views

Published on

PocketIO is perl's implementation for socket.io, a realtime web library originally written in JS.

In this keynote I present the concepts of real-time web, and how to use it in perl

Published in: Technology
  • Be the first to comment

RealTime Web with PocketIO

  1. 1. Realtime Web with PocketIO Ynon Perek Tel Aviv Perl MongersSaturday, November 24, 12
  2. 2. Whoami ✤ Ynon Perek ✤ ynonperek.com ✤ me@ynonperek.comSaturday, November 24, 12
  3. 3. Agenda ✤ What’s wrong with HTTP ✤ Real Time Web - Concepts ✤ PocketIO Coding DemosSaturday, November 24, 12
  4. 4. What is wrong with HTTP ? GET page Here It IsSaturday, November 24, 12
  5. 5. Let’s try a Live ChatSaturday, November 24, 12
  6. 6. HTTP Live Chat ✤ All communication is mediated by server using HTTP Tell Laura I Love HerSaturday, November 24, 12
  7. 7. HTTP Live Chat ✤ But the server can only reply ... Ok, got itSaturday, November 24, 12
  8. 8. HTTP Live Chat ✤ Waiting...Saturday, November 24, 12
  9. 9. HTTP Live Chat ✤ Meantime, on Laura’s side Do I have any messages ? Tommy said he loves youSaturday, November 24, 12
  10. 10. A second laterSaturday, November 24, 12
  11. 11. HTTP Live Chat Do I have any new messages ? No, sorrySaturday, November 24, 12
  12. 12. A second laterSaturday, November 24, 12
  13. 13. HTTP Live Chat Do I have any new messages ? No, sorrySaturday, November 24, 12
  14. 14. A second laterSaturday, November 24, 12
  15. 15. HTTP Live Chat Do I have any new messages ? No, sorrySaturday, November 24, 12
  16. 16. HTTP Live Chat Dark Side ✤ Server is busy picking up requests ✤ Clients are busy polling ✤ Everyone losesSaturday, November 24, 12
  17. 17. Real Time Web ✤ Improved UX by allowing the server to notify a clientSaturday, November 24, 12
  18. 18. What’s Available ✤ Plugins (usually flash) to open client/server sockets ✤ Comet ✤ Web Sockets (modern browsers)Saturday, November 24, 12
  19. 19. Meet PocketIO Perl implementation of Socket.IO written by vtiSaturday, November 24, 12
  20. 20. The Good ✤ Chooses the best available transport layer ✤ Manages active connections and reconnections ✤ AwesomeSaturday, November 24, 12
  21. 21. Coding TimeSaturday, November 24, 12
  22. 22. What You Need ✤ Use Twiggy (or fliggy) ✤ Use Plack::BuilderSaturday, November 24, 12
  23. 23. What You Need ✤ /socket.io/socket.io.js should point to the client-side library mount /socket.io/socket.io.js => Plack::App::File->new( file => "$root/public/javascripts/socket.io.js");Saturday, November 24, 12
  24. 24. What You Need ✤ /socket.io should return a new PocketIO object mount /socket.io => PocketIO->new( class => PocketHandler, method => run, ); Method that returns a subroutine reference to bind socket actionsSaturday, November 24, 12
  25. 25. PocketIO::Run ✤ Demo 1: Echo ServerSaturday, November 24, 12
  26. 26. PocketIO Broadcasts ✤ notify all except sender: $sender->broadcast->emit(‘message’, ‘text’); ✤ notify all (including sender) $sender->sockets->emit(‘message’, ‘text’); ✤ send an object $sender->sockets->emit(‘message’, { message => ‘text’ });Saturday, November 24, 12
  27. 27. PocketIO Broadcasts ✤ Demo2: Shared Echo (wall) ✤ Let’s turn our wall to multi-user wallSaturday, November 24, 12
  28. 28. PocketIO Sharing Data ✤ Use an external data store (DB, Redis) ✤ Use PlackSaturday, November 24, 12
  29. 29. External Data Store Shared Data Store PocketIO DancerSaturday, November 24, 12
  30. 30. Plack ✤ Create a shared variable in Plack::Builder (or a middleware) ✤ Pass it to all apps ✤ DemoSaturday, November 24, 12
  31. 31. PocketIO Takeaways ✤ Bring users closer together by allowing smooth collaboration ✤ Improve UX ✤ Multiplayer Zombie Slaying games FTWSaturday, November 24, 12
  32. 32. Thank You ✤ Keynote’s available at: http://www.slideshare.net/YnonPerek ✤ Code available at: https://github.com/ynonp/pm-nov-12 ✤ Visit me on: http://mobileweb.ynonperek.comSaturday, November 24, 12

×