Ajax Blog


pi.comet: simple comet library

Posted in Ajax News by Dion Almaer on the March 18th, 2008

Azer Koçulu thinks that you can create a comet application in 3 minutes with his new library pi.comet. It provides realtime data transfers between client and server.You can use pi.comet with any server side language.

The usage is very simple indeed:

JAVASCRIPT:
  1.  
  2. var request = new pi.comet();
  3. request.environment.setUrl("push.php");
  4. request.event.push = function(RESPONSE){
  5.           alert(RESPONSE);
  6. };
  7. request.send();
  8.  

And the style of client side comet depends on the type of browser:

JAVASCRIPT:
  1.  
  2. scope.comet.constructor = function(){
  3.         this.environment.setName("piComet");
  4.         this.environment.setType(scope.env.ie?3:scope.env.opera?2:1);
  5.         this.environment.setTunnel(
  6.                 this.environment.getType()==3?new ActiveXObject("htmlfile"):
  7.                 this.environment.getType()==2?document.createElement("event-source"):
  8.                 new scope.xhr
  9.         );
  10. }
  11.  

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/253614675/picomet-simple-comet-library

Comments are closed.