pi.comet: simple comet library
Date : 2008 03 18 Category : Tech & DevelopmentAzer 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:
PLAIN TEXT 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:
PLAIN TEXT 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 ); }