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

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
Roger Kitain
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi 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 Conference
rajivmordani
 
Ajax World 08 Asp Net Ajax
Ajax World 08 Asp Net AjaxAjax World 08 Asp Net Ajax
Ajax World 08 Asp Net Ajax
rajivmordani
 
Ajax World 08 Silverlight2 Overview
Ajax World 08 Silverlight2 OverviewAjax World 08 Silverlight2 Overview
Ajax World 08 Silverlight2 Overview
rajivmordani
 
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
rajivmordani
 
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
rajivmordani
 
Crafting Rich Web Experiences
Crafting Rich Web ExperiencesCrafting Rich Web Experiences
Crafting Rich Web Experiences
rajivmordani
 
Men\ S Bible Study Oct21 2008
Men\ S Bible Study Oct21 2008Men\ S Bible Study Oct21 2008
Men\ S Bible Study Oct21 2008
BertBrim
 
X Aware Ajax World V1
X Aware Ajax World V1X Aware Ajax World V1
X Aware Ajax World V1
rajivmordani
 
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
rajivmordani
 
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
rajivmordani
 
Digital Jacknife Aja Xevangerber
Digital Jacknife Aja XevangerberDigital Jacknife Aja Xevangerber
Digital Jacknife Aja Xevangerber
rajivmordani
 
Egl Rui Ajax World
Egl Rui Ajax WorldEgl Rui Ajax World
Egl Rui Ajax World
rajivmordani
 
Sue Googe Spice Up Ux
Sue Googe Spice Up UxSue Googe Spice Up Ux
Sue Googe Spice Up Ux
rajivmordani
 
Slow Cool 20081009 Final
Slow Cool 20081009 FinalSlow Cool 20081009 Final
Slow Cool 20081009 Final
rajivmordani
 
Ajax World Preso 100908adampolansky
Ajax World Preso 100908adampolanskyAjax World Preso 100908adampolansky
Ajax World Preso 100908adampolansky
rajivmordani
 

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

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
Viktor Gamov
 

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 Jsf
rajivmordani
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
rajivmordani
 
Tripit Ajaxworld V5
Tripit Ajaxworld V5Tripit Ajaxworld V5
Tripit Ajaxworld V5
rajivmordani
 
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
rajivmordani
 
Social Networking Intranet
Social Networking IntranetSocial Networking Intranet
Social Networking Intranet
rajivmordani
 
Server Side Javascript
Server Side JavascriptServer Side Javascript
Server Side Javascript
rajivmordani
 
Netapp Michael Galpin
Netapp Michael GalpinNetapp Michael Galpin
Netapp Michael Galpin
rajivmordani
 
Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008Laird Best Practices Ajax World West2008
Laird Best Practices Ajax World West2008
rajivmordani
 
Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1Java Fx Ajaxworld Rags V1
Java Fx Ajaxworld Rags V1
rajivmordani
 
Good Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas CrockfordGood Parts of JavaScript Douglas Crockford
Good Parts of JavaScript Douglas Crockford
rajivmordani
 
Flying Pixels Ent Apps Jeremy Chone
Flying Pixels Ent Apps Jeremy ChoneFlying Pixels Ent Apps Jeremy Chone
Flying Pixels Ent Apps Jeremy Chone
rajivmordani
 
I Phone Presentation Jan Linden Gips
I Phone Presentation Jan Linden GipsI Phone Presentation Jan Linden Gips
I Phone Presentation Jan Linden Gips
rajivmordani
 
Flex Flash And On Demand
Flex Flash And On DemandFlex Flash And On Demand
Flex Flash And On Demand
rajivmordani
 
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
rajivmordani
 
I Phone Summit Dmeeker Final
I Phone Summit Dmeeker FinalI Phone Summit Dmeeker Final
I Phone Summit Dmeeker Final
rajivmordani
 
Interoperable Ajax Tools And Mashups Ferraiolo
Interoperable Ajax Tools And Mashups FerraioloInteroperable Ajax Tools And Mashups Ferraiolo
Interoperable Ajax Tools And Mashups Ferraiolo
rajivmordani
 

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

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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...
 
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 convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

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