SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
Reverse-Ajax

    Par Mathieu Carbou, le 17 avril 2011




       Samples à https://github.com/Ovea/conf-reverse-ajax


Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Reverse Ajax refers to an Ajax design
   pattern   that   uses    long-lived   HTTP
   connections     to    enable   low-latency
   communication between a web server and a
   browser. Basically it is a way of sending
   data from client to server and a mechanism
   for pushing server data back to the
   browser.




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Event-Driven Web Applications




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Reverse-Ajax techniques


        1.     Polling
        2.     Piggyback
        3.     Comet
        4.     WebSockets



Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Polling


    I.e. Check for messages each 4 seconds




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Polling



                                 DEMO




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
2. Piggyback


    Check for messages when an action is
    performed.




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
2. Piggyback



                                 DEMO




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Comet


    A long-held HTTP request allows a web
    server to push data to a browser, without
    the browser explicitly requesting it.




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Comet techniques

        1.Long polling
          ● XMLHttpRequest
          ● Script tag

        2.Stream based
          ● Forever Iframe
          ● XMLHttpRequest Multipart
Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Comet



                                 DEMO

            XMLHttpRequest Long Polling
             (with Jetty Coninuations)

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Comet



                                 DEMO

          XMLHttpRequest Multipart
         (with Jetty Coninuations)

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Comet



                                 DEMO

            XMLHttpRequest Multipart
             (with Servlet 3.0 API)

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
4. WebSockets


    WebSocket & FlashSockets

    WebSocket is a technology providing for
    bi-directional, full-duplex
    communications channels. It is designed
    to be implemented in web browsers and web
    servers but it can be used by any client
    or server application .

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
4. WebSockets



                                 DEMO




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Reverse-Ajax for Java

    ●   Cannot use standard Servlets
    ●   Cannot use blocking I/O
    ●   Cannot retain request thread

        => Needs NIO + Features



Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Reverse-Ajax for Java

        You need 3 things:

    1. A good server (NIO)

    2. A good client library

    3. A good backend library
Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Servers


     ●   Jetty 8 (WebSocket, Comet)
     ●   Grizzly (WebSocket, Comet)
     ●   Tomcat 7 (Comet)

     ●   All Servlet 3.0 based


Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Servers

     ● For WebSocket: only native, per
     container (i.e. WebSocketServlet)

     ● For Comet: Servlet 3.0
     containers, Jetty Continuations

     ●   Polling, Piggyback anywhere

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Libraries


        1.     Socket.IO
        2.     Atmosphere
        3.     Cometd Bayeux
        4.     [...]



Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Socket.IO (transports)


        ●   WebSocket
        ●   Adobe Flash Socket
        ●   Comet Long Polling
        ●   Comet Multipart Streaming
        ●   Comet Forever Iframe
        ●   JSONP Polling

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Socket.IO (client)

    ● Very good API
    ● Desktop & Mobile & Client-Server

    ● Fallback, reconnect, offline

    messages, event-driven, …

    ●   Event-Driven bridge (Ovea)

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Socket.IO (client)

        ●   Internet Explorer 5.5 – 8
        ●   Safari 3 - 5
        ●   Google Chrome 4 - 6
        ●   Firefox 3-4
        ●   Opera 10.61
        ●   iPhone Safari
        ●   iPad Safari
        ●   Android WebKit
        ●   WebOs WebKit
Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Socket.IO-Java


    ●   Jetty Continuations (portable in
    any container)
    ● Native Jetty Websockets

    ● Servlet 3.0 support




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
1. Socket.IO



                                 DEMO




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Event-Driven Web



                                 DEMO

            Socket.IO + Ovea EventBus


Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
2. Atmosphere (transports)

      ●   WebSocket
      ●   Comet (Polling & Streaming)




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
2. Atmosphere (client)

      ●   Currently limited !
      ●   JQuery integration

      ●   BUT integration is possible
           ● With Cometd
           ● Socket.IO (to come ?)

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
2. Atmosphere (java)

      ●   Nearly all containers
      ●   Best native support
      ●   Container detection
      ●   WebSocket




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
2. Atmosphere



                                 DEMO




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Cometd (transports)

      ●   WebSocket
      ●   Comet Long Polling
      ●   JSONP Polling

      ● The most reliable and
      performant

Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Cometd (client)


    ● Event-based
    ● Jquery / Dojo

    ● Desktop & Mobile & Client-

    Server, Any Browser
    ● Extensions

    ● Very good API




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Cometd (java)


    ●   Jetty Continuations (portable in
    any container)
    ● Native Jetty Websockets

    ● Servlet 3.0 support




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
3. Cometd



                                 DEMO




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Resources (info)


       ➔   Exploring Reverse AJAX
       ➔   Comet
       ➔   WebSocket
       ➔   Portable Jetty Continuations




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Resources (projects)


       ➔   EventBus
       ➔   Socket.IO
       ➔   Socket.IO (Java)
       ➔   Atmosphere
       ➔   Cometd Bayeux




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com
Reverse-Ajax

                            QUESTIONS ?




Site: http://lab.ovea.com/
Blog: http://blog.mycila.com
Mail: mathieu.carbou@gmail.com

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Websocket 101 in Python
Websocket 101 in PythonWebsocket 101 in Python
Websocket 101 in Python
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbited
 
Automated Releases to RubyGems.org using Travis-CI.org
Automated Releases to RubyGems.org using Travis-CI.orgAutomated Releases to RubyGems.org using Travis-CI.org
Automated Releases to RubyGems.org using Travis-CI.org
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
 
HTTP2 is Here!
HTTP2 is Here!HTTP2 is Here!
HTTP2 is Here!
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Using Modern Browser APIs to Improve the Performance of Your Web Applications
Using Modern Browser APIs to Improve the Performance of Your Web ApplicationsUsing Modern Browser APIs to Improve the Performance of Your Web Applications
Using Modern Browser APIs to Improve the Performance of Your Web Applications
 
The MetaCPAN VM for Dummies Part One (Installation)
The MetaCPAN VM for Dummies Part One (Installation)The MetaCPAN VM for Dummies Part One (Installation)
The MetaCPAN VM for Dummies Part One (Installation)
 
Measuring Continuity
Measuring ContinuityMeasuring Continuity
Measuring Continuity
 
Full-Stack Plone Deployment with Ansible
Full-Stack Plone Deployment with AnsibleFull-Stack Plone Deployment with Ansible
Full-Stack Plone Deployment with Ansible
 
webworkers
webworkerswebworkers
webworkers
 
Performance Improvements in Browsers
Performance Improvements in BrowsersPerformance Improvements in Browsers
Performance Improvements in Browsers
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
 
Learnings from govuk
Learnings from govukLearnings from govuk
Learnings from govuk
 
Apache TomEE, Java EE 6 Web Profile {and more} on Tomcat
Apache TomEE, Java EE 6 Web Profile {and more} on TomcatApache TomEE, Java EE 6 Web Profile {and more} on Tomcat
Apache TomEE, Java EE 6 Web Profile {and more} on Tomcat
 
Plone Deployment Secrets & Tricks
Plone Deployment Secrets & TricksPlone Deployment Secrets & Tricks
Plone Deployment Secrets & Tricks
 
Plone Deployment (PloneConf Edition)
Plone Deployment (PloneConf Edition)Plone Deployment (PloneConf Edition)
Plone Deployment (PloneConf Edition)
 

Similar a Reverse Ajax

Websockets at tossug
Websockets at tossugWebsockets at tossug
Websockets at tossug
clkao
 
V2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketV2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocket
brent bucci
 
Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010
sullis
 
Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010
sullis
 
Peter lubbers-html5-offline-web-apps
Peter lubbers-html5-offline-web-appsPeter lubbers-html5-offline-web-apps
Peter lubbers-html5-offline-web-apps
Skills Matter
 

Similar a Reverse Ajax (20)

Redis Introduction
Redis IntroductionRedis Introduction
Redis Introduction
 
Websockets at tossug
Websockets at tossugWebsockets at tossug
Websockets at tossug
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Rails 生態圈一覽
Rails 生態圈一覽Rails 生態圈一覽
Rails 生態圈一覽
 
V2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketV2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocket
 
Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010Programming WebSockets - April 20 2010
Programming WebSockets - April 20 2010
 
Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010Programming WebSockets - OSCON 2010
Programming WebSockets - OSCON 2010
 
Selenium cloud
Selenium cloudSelenium cloud
Selenium cloud
 
The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Peter lubbers-html5-offline-web-apps
Peter lubbers-html5-offline-web-appsPeter lubbers-html5-offline-web-apps
Peter lubbers-html5-offline-web-apps
 
Web Standards Support in WebKit
Web Standards Support in WebKitWeb Standards Support in WebKit
Web Standards Support in WebKit
 
Graph ql subscriptions through the looking glass
Graph ql subscriptions through the looking glassGraph ql subscriptions through the looking glass
Graph ql subscriptions through the looking glass
 
Graph ql subscriptions on the jvm
Graph ql subscriptions on the jvmGraph ql subscriptions on the jvm
Graph ql subscriptions on the jvm
 
ONAP MultiCloud/K8s Casablanca
ONAP MultiCloud/K8s CasablancaONAP MultiCloud/K8s Casablanca
ONAP MultiCloud/K8s Casablanca
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Going Headless with Craft CMS 3.3
Going Headless with Craft CMS 3.3Going Headless with Craft CMS 3.3
Going Headless with Craft CMS 3.3
 
HTTP colon slash slash: end of the road? @ CakeFest 2013 in San Francisco
HTTP colon slash slash: end of the road? @ CakeFest 2013 in San FranciscoHTTP colon slash slash: end of the road? @ CakeFest 2013 in San Francisco
HTTP colon slash slash: end of the road? @ CakeFest 2013 in San Francisco
 
Real-Time Web applications with WebSockets
Real-Time Web applications with WebSocketsReal-Time Web applications with WebSockets
Real-Time Web applications with WebSockets
 
WebGL Awesomeness
WebGL AwesomenessWebGL Awesomeness
WebGL Awesomeness
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Reverse Ajax

  • 1. Reverse-Ajax Par Mathieu Carbou, le 17 avril 2011 Samples à https://github.com/Ovea/conf-reverse-ajax Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 2. Reverse Ajax refers to an Ajax design pattern that uses long-lived HTTP connections to enable low-latency communication between a web server and a browser. Basically it is a way of sending data from client to server and a mechanism for pushing server data back to the browser. Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 4. Reverse-Ajax techniques 1. Polling 2. Piggyback 3. Comet 4. WebSockets Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 5. 1. Polling I.e. Check for messages each 4 seconds Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 6.
  • 7. 1. Polling DEMO Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 8. 2. Piggyback Check for messages when an action is performed. Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 9.
  • 10. 2. Piggyback DEMO Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 11. 3. Comet A long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it. Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 12.
  • 13. 3. Comet techniques 1.Long polling ● XMLHttpRequest ● Script tag 2.Stream based ● Forever Iframe ● XMLHttpRequest Multipart Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 14. 3. Comet DEMO XMLHttpRequest Long Polling (with Jetty Coninuations) Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 15. 3. Comet DEMO XMLHttpRequest Multipart (with Jetty Coninuations) Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 16. 3. Comet DEMO XMLHttpRequest Multipart (with Servlet 3.0 API) Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 17. 4. WebSockets WebSocket & FlashSockets WebSocket is a technology providing for bi-directional, full-duplex communications channels. It is designed to be implemented in web browsers and web servers but it can be used by any client or server application . Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 18.
  • 19. 4. WebSockets DEMO Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 20. Reverse-Ajax for Java ● Cannot use standard Servlets ● Cannot use blocking I/O ● Cannot retain request thread => Needs NIO + Features Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 21. Reverse-Ajax for Java You need 3 things: 1. A good server (NIO) 2. A good client library 3. A good backend library Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 22. Servers ● Jetty 8 (WebSocket, Comet) ● Grizzly (WebSocket, Comet) ● Tomcat 7 (Comet) ● All Servlet 3.0 based Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 23. Servers ● For WebSocket: only native, per container (i.e. WebSocketServlet) ● For Comet: Servlet 3.0 containers, Jetty Continuations ● Polling, Piggyback anywhere Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 24. Libraries 1. Socket.IO 2. Atmosphere 3. Cometd Bayeux 4. [...] Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 25. 1. Socket.IO (transports) ● WebSocket ● Adobe Flash Socket ● Comet Long Polling ● Comet Multipart Streaming ● Comet Forever Iframe ● JSONP Polling Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 26. 1. Socket.IO (client) ● Very good API ● Desktop & Mobile & Client-Server ● Fallback, reconnect, offline messages, event-driven, … ● Event-Driven bridge (Ovea) Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 27. 1. Socket.IO (client) ● Internet Explorer 5.5 – 8 ● Safari 3 - 5 ● Google Chrome 4 - 6 ● Firefox 3-4 ● Opera 10.61 ● iPhone Safari ● iPad Safari ● Android WebKit ● WebOs WebKit Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 28. 1. Socket.IO-Java ● Jetty Continuations (portable in any container) ● Native Jetty Websockets ● Servlet 3.0 support Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 29. 1. Socket.IO DEMO Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 30. Event-Driven Web DEMO Socket.IO + Ovea EventBus Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 31. 2. Atmosphere (transports) ● WebSocket ● Comet (Polling & Streaming) Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 32. 2. Atmosphere (client) ● Currently limited ! ● JQuery integration ● BUT integration is possible ● With Cometd ● Socket.IO (to come ?) Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 33. 2. Atmosphere (java) ● Nearly all containers ● Best native support ● Container detection ● WebSocket Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 34. 2. Atmosphere DEMO Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 35. 3. Cometd (transports) ● WebSocket ● Comet Long Polling ● JSONP Polling ● The most reliable and performant Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 36. 3. Cometd (client) ● Event-based ● Jquery / Dojo ● Desktop & Mobile & Client- Server, Any Browser ● Extensions ● Very good API Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 37. 3. Cometd (java) ● Jetty Continuations (portable in any container) ● Native Jetty Websockets ● Servlet 3.0 support Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 38. 3. Cometd DEMO Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 39. Resources (info) ➔ Exploring Reverse AJAX ➔ Comet ➔ WebSocket ➔ Portable Jetty Continuations Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 40. Resources (projects) ➔ EventBus ➔ Socket.IO ➔ Socket.IO (Java) ➔ Atmosphere ➔ Cometd Bayeux Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com
  • 41. Reverse-Ajax QUESTIONS ? Site: http://lab.ovea.com/ Blog: http://blog.mycila.com Mail: mathieu.carbou@gmail.com