pi.comet: simple comet library
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:
-
-
var request = new pi.comet();
-
request.environment.setUrl("push.php");
-
request.event.push = function(RESPONSE){
-
alert(RESPONSE);
-
};
-
request.send();
-
And the style of client side comet depends on the type of browser:
JAVASCRIPT:
-
-
scope.comet.constructor = function(){
-
this.environment.setName("piComet");
-
this.environment.setType(scope.env.ie?3:scope.env.opera?2:1);
-
this.environment.setTunnel(
-
this.environment.getType()==3?new ActiveXObject("htmlfile"):
-
this.environment.getType()==2?document.createElement("event-source"):
-
new scope.xhr
-
);
-
}
-
Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/253614675/picomet-simple-comet-library