SlideShare a Scribd company logo
1 of 33
Download to read offline
Pushing Data to the Browser
           with Comet
                    by Kevin Nilson
             http://www.javaclimber.com


AjaxWorld 2008
http://ajaxworld.com
Wednesday October 22, 2008
9:50 - 10:35am
Kevin Nilson

Kevin Nilson is currently a Principal Software Architect for a Large Financial Institute in
Silicon Valley. He is the co-lead of the Silicon Valley Web Developer JUG. He is also the
co-lead of the Silicon Valley Google Technology User Group.

Prior to his current work, Kevin had extensive industry software engineering and consulting
experience with companies such as: Pfizer, Northrop Grumman, AT&T Corporation, etc.
He also worked part-time as an adjunct professor at the College of San Mateo.

Kevin received a Bachelor's degree in Computer Science with a Minor in Mathematics from
Southern Illinois University in Carbondale and a Masters degree in Computer Science from
Southern Illinois University in Edwardsville. He is a Sun Certified Java Programmer and
Sun Certified Web Component Developer.

You can learn more about Kevin on his website JavaClimber.com.
Ajax

What is Ajax?
  Client Browser calling webpage to get data to update a
  page
  Many great JavaScript Ajax Framworks
  JSON often used
Uses of Ajax

  Fill Drop-downs to support selecting: State, County, then
  City
  Drill-down in reporting
  verify form data
  adding route to map
Ajax Limitations

Based on Client Request, not server state change.

   Chat Application
   Stock Updates
   Temperature Update
   Server Load, Server Processes, Current Sessions
   JMS ...

Polling is the best you can do with Ajax
What is Comet

 Allows data to be pushed to the browser from the server
 Sometimes called Reverse Ajax
 Challenge because HTTP is a connectionless protocol
 Long Polling and Streaming are considered Comet (next)
 Push data to the browser without install
     Requires accepting quot;scaryquot; dialog, configuration, ....
     Applet
     Flash
Uses of Comet

 Chat Application
 Stock Updates
 Temperature Update
 Server Load, Server Processes, Current Sessions
 JMS ...
Polling (Option 1)
Polling
Polling Demo
Long Polling (Option 2)
Long Polling
Long Polling - Chat
( javaclimber.com )
Long Polling Demo
Streaming (Option 3)
Streaming
Ajax vs Comet
Challenges

Client Side
    2 request limit per domain

Server Side
   Servlet = 1 thread per request
   Continuation added to Servlet 3
Bayeux
 Only Open Standard for Comet, (Open Source)
 Publish / Subscribe
 In Draft
 Multiple Client and Server Implementations
     Client
         Dojo
         JQuery
         ExtJs
         flexcomet ...
     Server
         Jetty
         Tomcat
         WebSphere
         Weblogic
         Cometd-twisted (python)
         Cometd-perl
Bayeux Sensor Demo
Bayeux JavaScript - Publish

var text = 'hello';

dojox.cometd.publish(quot;/chatquot;, { chat: text});
Bayeux JavaScript - Subscribe

dojox.cometd.init(quot;http://localhost:8080/cometdquot;);
dojox.cometd.subscribe(quot;/chatquot;, myapp, quot;chatMessagequot;);

chatMessage: function(message){
    if(!message.data){
        alert(quot;bad chat data quot;+message);
    } else {
        updateChatDisplay(message.data.chat);
    }
}
Bayeux - Reconnect
myapp._meta=dojo.subscribe(quot;/cometd/metaquot;,
  dojo.hitch(this,function(event){
  if (event.action==quot;handshakequot;) {
  } else if (event.action==quot;connectquot;) {
    if (event.successful && !this._connected){
      //user is reconnected
    }
    if (!event.successful && this._connected){
      //user is disconnected
    }
    this._connected=event.successful;
  }
}));
Bayeux - Java - Publish

public void publish(String channel, Map<String, Object> data) {
     if(getBayeux().hasChannel(channel)){
        Channel c = getBayeux().
        getChannel(channel, false);
        c.publish(getClient(), data,quot;fromserverquot;);
     }else{
        //oops no subscribers
     }
  }
Bayeux - Java - Subscribe &
Unsubscribe
super.subscribe(channel, method);

Channel c = bayeux.getChannel(channelStr,
 true);
c.unsubscribe(getClient());
Bayeux - Java - Remove Notification

client.addListener(new RemoveListener( ){
   public void removed(String clientId,
      boolean timeout){

          //do something to clean-up

      }
});
Bayeux - Java - Security

public interface SecurityPolicy
{
  boolean canHandshake(Message message);
  boolean canCreate(Client client,String
     channel,Message message);
  boolean canSubscribe(Client client,String
     channel,Message messsage);
  boolean canPublish(Client client,String
     channel,Message messsage);
}
Bayeux - Java - Request

AbstractBayeux b = (AbstractBayeux)
    getBayeux();
if (b.isRequestAvailable())
  HttpServletRequest request =
    b.getCurrentRequest();

web.xml, add to cometd servlet
<init-param>
<param-name>requestAvailable</param-name>
<param-value>true</param-value>
</init-param>
Bayeux - Java - Request

AbstractBayeux b = (AbstractBayeux)
    getBayeux();
if (b.isRequestAvailable())
  HttpServletRequest request =
    b.getCurrentRequest();

web.xml, add to cometd servlet
<init-param>
<param-name>requestAvailable</param-name>
<param-value>true</param-value>
</init-param>
Cometd Chat Demo
Bayeux - Misconceptions

Many Believe Bayeux is only for Pub/Sub, but this is not
true. Two special channels exist for RPC style requests

   meta channels
   service channels
Future

HTML5 brings WebSockets
  Full Spec Completes 2022, but WebSockets spec is very
  mature
  Text based, so name is a bit confusing
Questions
Article by Kevin Nilson
Pushing Data to the Browser with Comet by Kevin Nilson
http://www.developer.com/services/article.
php/10928_3756841


Upcoming Speaking Events with Kevin Nilson
The Chronicles of Web Standard: the HTML 5, the Comet
and the WebSocket
10/29/2008 - Silicon Valley Web Builder
http://tinyurl.com/webstandard

An Introduction to Comet and Bayeux
November 8-9, 2008 Silicon Valley Code Camp
http://www.siliconvalley-codecamp.com

More Related Content

What's hot

Java - Servlet - Mazenet Solution
Java - Servlet - Mazenet SolutionJava - Servlet - Mazenet Solution
Java - Servlet - Mazenet SolutionMazenetsolution
 
Comet from JavaOne 2008
Comet from JavaOne 2008Comet from JavaOne 2008
Comet from JavaOne 2008Joe Walker
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2Rob Tweed
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7Roberto Cortez
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
 
Using Websockets in Play !
Using Websockets in Play !Using Websockets in Play !
Using Websockets in Play !Knoldus Inc.
 
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...Rob Tweed
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationMicha Kops
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal kotecha
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integrationOleksandr Semenov
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsJavaEE Trainers
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django ChannelsAlbert O'Connor
 
HTML5 Server Sent Events/JSF JAX 2011 Conference
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 ConferenceRoger Kitain
 
Java Servlets
Java ServletsJava Servlets
Java ServletsEmprovise
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsi krishna
 

What's hot (20)

Java - Servlet - Mazenet Solution
Java - Servlet - Mazenet SolutionJava - Servlet - Mazenet Solution
Java - Servlet - Mazenet Solution
 
Comet from JavaOne 2008
Comet from JavaOne 2008Comet from JavaOne 2008
Comet from JavaOne 2008
 
SERVIET
SERVIETSERVIET
SERVIET
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 2
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
 
Cgi
CgiCgi
Cgi
 
Using Websockets in Play !
Using Websockets in Play !Using Websockets in Play !
Using Websockets in Play !
 
Servlets
ServletsServlets
Servlets
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
EWD 3 Training Course Part 13: Putting Everything so far into Practice using ...
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servlets
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django Channels
 
HTML5 Server Sent Events/JSF JAX 2011 Conference
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 Conference
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Servlets
ServletsServlets
Servlets
 

Viewers also liked

2008 Ajax World Conference
2008 Ajax World Conference2008 Ajax World Conference
2008 Ajax World Conferencerajivmordani
 
Ajax World 08 Asp Net Ajax
Ajax World 08 Asp Net AjaxAjax World 08 Asp Net Ajax
Ajax World 08 Asp Net Ajaxrajivmordani
 
Ajax World 08 Silverlight2 Overview
Ajax World 08 Silverlight2 OverviewAjax World 08 Silverlight2 Overview
Ajax World 08 Silverlight2 Overviewrajivmordani
 
Practical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter SvenssonPractical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter Svenssonrajivmordani
 
Mike Grushin Developing Ugc Sites That Scale
Mike Grushin    Developing Ugc Sites That ScaleMike Grushin    Developing Ugc Sites That Scale
Mike Grushin Developing Ugc Sites That Scalerajivmordani
 
Crafting Rich Web Experiences
Crafting Rich Web ExperiencesCrafting Rich Web Experiences
Crafting Rich Web Experiencesrajivmordani
 
Some Random Moodle Stuff
Some Random Moodle StuffSome Random Moodle Stuff
Some Random Moodle StuffKevin Hughes
 
Men\ S Bible Study Oct21 2008
Men\ S Bible Study Oct21 2008Men\ S Bible Study Oct21 2008
Men\ S Bible Study Oct21 2008BertBrim
 
X Aware Ajax World V1
X Aware Ajax World V1X Aware Ajax World V1
X Aware Ajax World V1rajivmordani
 
Flex Air Mobile Nicholas Thomas Aja Xworld2008
Flex  Air  Mobile Nicholas Thomas Aja Xworld2008Flex  Air  Mobile Nicholas Thomas Aja Xworld2008
Flex Air Mobile Nicholas Thomas Aja Xworld2008rajivmordani
 
I Phone Dev Summit Prezo Guy Naor Final
I Phone Dev Summit Prezo Guy Naor FinalI Phone Dev Summit Prezo Guy Naor Final
I Phone Dev Summit Prezo Guy Naor Finalrajivmordani
 
Digital Jacknife Aja Xevangerber
Digital Jacknife Aja XevangerberDigital Jacknife Aja Xevangerber
Digital Jacknife Aja Xevangerberrajivmordani
 
Egl Rui Ajax World
Egl Rui Ajax WorldEgl Rui Ajax World
Egl Rui Ajax Worldrajivmordani
 
Sue Googe Spice Up Ux
Sue Googe Spice Up UxSue Googe Spice Up Ux
Sue Googe Spice Up Uxrajivmordani
 
Slow Cool 20081009 Final
Slow Cool 20081009 FinalSlow Cool 20081009 Final
Slow Cool 20081009 Finalrajivmordani
 
Ajax World Preso 100908adampolansky
Ajax World Preso 100908adampolanskyAjax World Preso 100908adampolansky
Ajax World Preso 100908adampolanskyrajivmordani
 

Viewers also liked (20)

2008 Ajax World Conference
2008 Ajax World Conference2008 Ajax World Conference
2008 Ajax World Conference
 
Ajax World 08 Asp Net Ajax
Ajax World 08 Asp Net AjaxAjax World 08 Asp Net Ajax
Ajax World 08 Asp Net Ajax
 
Ajax World 08 Silverlight2 Overview
Ajax World 08 Silverlight2 OverviewAjax World 08 Silverlight2 Overview
Ajax World 08 Silverlight2 Overview
 
Practical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter SvenssonPractical Thin Server Architecture With Dojo Peter Svensson
Practical Thin Server Architecture With Dojo Peter Svensson
 
Mike Grushin Developing Ugc Sites That Scale
Mike Grushin    Developing Ugc Sites That ScaleMike Grushin    Developing Ugc Sites That Scale
Mike Grushin Developing Ugc Sites That Scale
 
Ajax World West
Ajax World WestAjax World West
Ajax World West
 
Crafting Rich Web Experiences
Crafting Rich Web ExperiencesCrafting Rich Web Experiences
Crafting Rich Web Experiences
 
Dmeeker Finala
Dmeeker FinalaDmeeker Finala
Dmeeker Finala
 
Some Random Moodle Stuff
Some Random Moodle StuffSome Random Moodle Stuff
Some Random Moodle Stuff
 
Men\ S Bible Study Oct21 2008
Men\ S Bible Study Oct21 2008Men\ S Bible Study Oct21 2008
Men\ S Bible Study Oct21 2008
 
X Aware Ajax World V1
X Aware Ajax World V1X Aware Ajax World V1
X Aware Ajax World V1
 
Flex Air Mobile Nicholas Thomas Aja Xworld2008
Flex  Air  Mobile Nicholas Thomas Aja Xworld2008Flex  Air  Mobile Nicholas Thomas Aja Xworld2008
Flex Air Mobile Nicholas Thomas Aja Xworld2008
 
I Phone Dev Summit Prezo Guy Naor Final
I Phone Dev Summit Prezo Guy Naor FinalI Phone Dev Summit Prezo Guy Naor Final
I Phone Dev Summit Prezo Guy Naor Final
 
Cloudy Ajax 08 10
Cloudy Ajax 08 10Cloudy Ajax 08 10
Cloudy Ajax 08 10
 
Digital Jacknife Aja Xevangerber
Digital Jacknife Aja XevangerberDigital Jacknife Aja Xevangerber
Digital Jacknife Aja Xevangerber
 
Egl Rui Ajax World
Egl Rui Ajax WorldEgl Rui Ajax World
Egl Rui Ajax World
 
Sue Googe Spice Up Ux
Sue Googe Spice Up UxSue Googe Spice Up Ux
Sue Googe Spice Up Ux
 
Slow Cool 20081009 Final
Slow Cool 20081009 FinalSlow Cool 20081009 Final
Slow Cool 20081009 Final
 
Ajax World Preso 100908adampolansky
Ajax World Preso 100908adampolanskyAjax World Preso 100908adampolansky
Ajax World Preso 100908adampolansky
 
I Phone Dev
I Phone DevI Phone Dev
I Phone Dev
 

Similar to Pushing Datatothe Browserwith Comet Ajax W

Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersoazabir
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and BeyondMarakana Inc.
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis Hassler
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...PROIDEA
 
The Windows Runtime and the Web
The Windows Runtime and the WebThe Windows Runtime and the Web
The Windows Runtime and the WebJeremy Likness
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersViktor Gamov
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITCarol McDonald
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websocketsWim Godden
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitAriya Hidayat
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitAriya Hidayat
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享Chia Wei Tsai
 
Enhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocketEnhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocketMauricio "Maltron" Leal
 

Similar to Pushing Datatothe Browserwith Comet Ajax W (20)

The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
WebSockets in JEE 7
WebSockets in JEE 7WebSockets in JEE 7
WebSockets in JEE 7
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and Beyond
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
 
The Windows Runtime and the Web
The Windows Runtime and the WebThe Windows Runtime and the Web
The Windows Runtime and the Web
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
Building interactivity with websockets
Building interactivity with websocketsBuilding interactivity with websockets
Building interactivity with websockets
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
Hybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKitHybrid Apps (Native + Web) using WebKit
Hybrid Apps (Native + Web) using WebKit
 
08 ajax
08 ajax08 ajax
08 ajax
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
 
Html5 websockets
Html5 websocketsHtml5 websockets
Html5 websockets
 
Enhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocketEnhancing Mobile User Experience with WebSocket
Enhancing Mobile User Experience with WebSocket
 

More from rajivmordani

Web 2 0 Data Visualization With Jsf
Web 2 0 Data Visualization With JsfWeb 2 0 Data Visualization With Jsf
Web 2 0 Data Visualization With Jsfrajivmordani
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
Tripit Ajaxworld V5
Tripit Ajaxworld V5Tripit Ajaxworld V5
Tripit Ajaxworld V5rajivmordani
 
Turbo Enterprise Web 2.0 Ajax World 20081
Turbo Enterprise Web 2.0 Ajax World 20081Turbo Enterprise Web 2.0 Ajax World 20081
Turbo Enterprise Web 2.0 Ajax World 20081rajivmordani
 
Social Networking Intranet
Social Networking IntranetSocial Networking Intranet
Social Networking Intranetrajivmordani
 
Server Side Javascript
Server Side JavascriptServer Side Javascript
Server Side Javascriptrajivmordani
 
Netapp Michael Galpin
Netapp Michael GalpinNetapp Michael Galpin
Netapp Michael Galpinrajivmordani
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008rajivmordani
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1rajivmordani
 
Good Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas CrockfordGood Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas Crockfordrajivmordani
 
Flying Pixels Ent Apps Jeremy Chone
Flying Pixels Ent Apps Jeremy ChoneFlying Pixels Ent Apps Jeremy Chone
Flying Pixels Ent Apps Jeremy Chonerajivmordani
 
I Phone Presentation Jan Linden Gips
I Phone Presentation Jan Linden GipsI Phone Presentation Jan Linden Gips
I Phone Presentation Jan Linden Gipsrajivmordani
 
Flex Flash And On Demand
Flex Flash And On DemandFlex Flash And On Demand
Flex Flash And On Demandrajivmordani
 
I Phone Dev Summit Lefty 03 07 08
I Phone Dev Summit Lefty 03 07 08I Phone Dev Summit Lefty 03 07 08
I Phone Dev Summit Lefty 03 07 08rajivmordani
 
I Phone Summit Dmeeker Final
I Phone Summit Dmeeker FinalI Phone Summit Dmeeker Final
I Phone Summit Dmeeker Finalrajivmordani
 
Interoperable Ajax Tools And Mashups Ferraiolo
Interoperable Ajax Tools And Mashups FerraioloInteroperable Ajax Tools And Mashups Ferraiolo
Interoperable Ajax Tools And Mashups Ferraiolorajivmordani
 

More from rajivmordani (20)

Web 2 0 Data Visualization With Jsf
Web 2 0 Data Visualization With JsfWeb 2 0 Data Visualization With Jsf
Web 2 0 Data Visualization With Jsf
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
Tripit Ajaxworld V5
Tripit Ajaxworld V5Tripit Ajaxworld V5
Tripit Ajaxworld V5
 
Turbo Enterprise Web 2.0 Ajax World 20081
Turbo Enterprise Web 2.0 Ajax World 20081Turbo Enterprise Web 2.0 Ajax World 20081
Turbo Enterprise Web 2.0 Ajax World 20081
 
Social Networking Intranet
Social Networking IntranetSocial Networking Intranet
Social Networking Intranet
 
Ssjs Presentation
Ssjs PresentationSsjs Presentation
Ssjs Presentation
 
Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
Server Side Javascript
Server Side JavascriptServer Side Javascript
Server Side Javascript
 
Ria Enterprise
Ria EnterpriseRia Enterprise
Ria Enterprise
 
Netapp Michael Galpin
Netapp Michael GalpinNetapp Michael Galpin
Netapp Michael Galpin
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1
 
Good Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas CrockfordGood Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas Crockford
 
Flying Pixels Ent Apps Jeremy Chone
Flying Pixels Ent Apps Jeremy ChoneFlying Pixels Ent Apps Jeremy Chone
Flying Pixels Ent Apps Jeremy Chone
 
I Phone Presentation Jan Linden Gips
I Phone Presentation Jan Linden GipsI Phone Presentation Jan Linden Gips
I Phone Presentation Jan Linden Gips
 
Flex Flash And On Demand
Flex Flash And On DemandFlex Flash And On Demand
Flex Flash And On Demand
 
I Phone Dev Summit Lefty 03 07 08
I Phone Dev Summit Lefty 03 07 08I Phone Dev Summit Lefty 03 07 08
I Phone Dev Summit Lefty 03 07 08
 
I Phone Summit Dmeeker Final
I Phone Summit Dmeeker FinalI Phone Summit Dmeeker Final
I Phone Summit Dmeeker Final
 
Ilog Ria2
Ilog Ria2Ilog Ria2
Ilog Ria2
 
Interoperable Ajax Tools And Mashups Ferraiolo
Interoperable Ajax Tools And Mashups FerraioloInteroperable Ajax Tools And Mashups Ferraiolo
Interoperable Ajax Tools And Mashups Ferraiolo
 

Recently uploaded

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Pushing Datatothe Browserwith Comet Ajax W

  • 1. Pushing Data to the Browser with Comet by Kevin Nilson http://www.javaclimber.com AjaxWorld 2008 http://ajaxworld.com Wednesday October 22, 2008 9:50 - 10:35am
  • 2. Kevin Nilson Kevin Nilson is currently a Principal Software Architect for a Large Financial Institute in Silicon Valley. He is the co-lead of the Silicon Valley Web Developer JUG. He is also the co-lead of the Silicon Valley Google Technology User Group. Prior to his current work, Kevin had extensive industry software engineering and consulting experience with companies such as: Pfizer, Northrop Grumman, AT&T Corporation, etc. He also worked part-time as an adjunct professor at the College of San Mateo. Kevin received a Bachelor's degree in Computer Science with a Minor in Mathematics from Southern Illinois University in Carbondale and a Masters degree in Computer Science from Southern Illinois University in Edwardsville. He is a Sun Certified Java Programmer and Sun Certified Web Component Developer. You can learn more about Kevin on his website JavaClimber.com.
  • 3. Ajax What is Ajax? Client Browser calling webpage to get data to update a page Many great JavaScript Ajax Framworks JSON often used
  • 4. Uses of Ajax Fill Drop-downs to support selecting: State, County, then City Drill-down in reporting verify form data adding route to map
  • 5. Ajax Limitations Based on Client Request, not server state change. Chat Application Stock Updates Temperature Update Server Load, Server Processes, Current Sessions JMS ... Polling is the best you can do with Ajax
  • 6. What is Comet Allows data to be pushed to the browser from the server Sometimes called Reverse Ajax Challenge because HTTP is a connectionless protocol Long Polling and Streaming are considered Comet (next) Push data to the browser without install Requires accepting quot;scaryquot; dialog, configuration, .... Applet Flash
  • 7. Uses of Comet Chat Application Stock Updates Temperature Update Server Load, Server Processes, Current Sessions JMS ...
  • 13. Long Polling - Chat ( javaclimber.com )
  • 18. Challenges Client Side 2 request limit per domain Server Side Servlet = 1 thread per request Continuation added to Servlet 3
  • 19. Bayeux Only Open Standard for Comet, (Open Source) Publish / Subscribe In Draft Multiple Client and Server Implementations Client Dojo JQuery ExtJs flexcomet ... Server Jetty Tomcat WebSphere Weblogic Cometd-twisted (python) Cometd-perl
  • 21. Bayeux JavaScript - Publish var text = 'hello'; dojox.cometd.publish(quot;/chatquot;, { chat: text});
  • 22. Bayeux JavaScript - Subscribe dojox.cometd.init(quot;http://localhost:8080/cometdquot;); dojox.cometd.subscribe(quot;/chatquot;, myapp, quot;chatMessagequot;); chatMessage: function(message){ if(!message.data){ alert(quot;bad chat data quot;+message); } else { updateChatDisplay(message.data.chat); } }
  • 23. Bayeux - Reconnect myapp._meta=dojo.subscribe(quot;/cometd/metaquot;, dojo.hitch(this,function(event){ if (event.action==quot;handshakequot;) { } else if (event.action==quot;connectquot;) { if (event.successful && !this._connected){ //user is reconnected } if (!event.successful && this._connected){ //user is disconnected } this._connected=event.successful; } }));
  • 24. Bayeux - Java - Publish public void publish(String channel, Map<String, Object> data) { if(getBayeux().hasChannel(channel)){ Channel c = getBayeux(). getChannel(channel, false); c.publish(getClient(), data,quot;fromserverquot;); }else{ //oops no subscribers } }
  • 25. Bayeux - Java - Subscribe & Unsubscribe super.subscribe(channel, method); Channel c = bayeux.getChannel(channelStr, true); c.unsubscribe(getClient());
  • 26. Bayeux - Java - Remove Notification client.addListener(new RemoveListener( ){ public void removed(String clientId, boolean timeout){ //do something to clean-up } });
  • 27. Bayeux - Java - Security public interface SecurityPolicy { boolean canHandshake(Message message); boolean canCreate(Client client,String channel,Message message); boolean canSubscribe(Client client,String channel,Message messsage); boolean canPublish(Client client,String channel,Message messsage); }
  • 28. Bayeux - Java - Request AbstractBayeux b = (AbstractBayeux) getBayeux(); if (b.isRequestAvailable()) HttpServletRequest request = b.getCurrentRequest(); web.xml, add to cometd servlet <init-param> <param-name>requestAvailable</param-name> <param-value>true</param-value> </init-param>
  • 29. Bayeux - Java - Request AbstractBayeux b = (AbstractBayeux) getBayeux(); if (b.isRequestAvailable()) HttpServletRequest request = b.getCurrentRequest(); web.xml, add to cometd servlet <init-param> <param-name>requestAvailable</param-name> <param-value>true</param-value> </init-param>
  • 31. Bayeux - Misconceptions Many Believe Bayeux is only for Pub/Sub, but this is not true. Two special channels exist for RPC style requests meta channels service channels
  • 32. Future HTML5 brings WebSockets Full Spec Completes 2022, but WebSockets spec is very mature Text based, so name is a bit confusing
  • 33. Questions Article by Kevin Nilson Pushing Data to the Browser with Comet by Kevin Nilson http://www.developer.com/services/article. php/10928_3756841 Upcoming Speaking Events with Kevin Nilson The Chronicles of Web Standard: the HTML 5, the Comet and the WebSocket 10/29/2008 - Silicon Valley Web Builder http://tinyurl.com/webstandard An Introduction to Comet and Bayeux November 8-9, 2008 Silicon Valley Code Camp http://www.siliconvalley-codecamp.com