/[meteor]/googlecode.com/svn/trunk/public_html/poll.html
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /googlecode.com/svn/trunk/public_html/poll.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 53 - (show annotations)
Wed Feb 27 21:58:56 2008 UTC (16 years, 1 month ago) by andrew.betts
File MIME type: text/html
File size: 2217 byte(s)
Updated version number

JS client:
Added channel info handler to JS client, assumes Meteor will send <script>ch('channel', msgid);</script>
Allowed processing of messages prior to current message index
Added disconnect() to eof()
Revert to poll mode if unable to load frame (should fix IE proxy issues)

Server:
Fixed output of channel info to show only subscribed channels (and simplified)
Added logging of IP addresses

1 <html>
2 <body>
3 <script type="text/javascript">
4 window.onError = null;
5 var domainparts = document.domain.split(".");
6 var thisdomain = document.domain;
7 var topdomain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];
8 document.domain = topdomain;
9 var lastrequesttime = 0;
10 var pollreq = null;
11 var polltimer = false;
12 var i=0;
13 var isaborted = 0;
14 parent.Meteor.register(this);
15
16 function newXmlHttp() {
17 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
18 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
19 try { return new XMLHttpRequest(); } catch(e) {}
20 return null;
21 }
22
23 function poll() {
24 isaborted = 0;
25 pollreq = null;
26 try {
27 clearTimeout(polltimer);
28 } catch (e) {}
29 var byteoffset = 0;
30 var newdata;
31 try {
32 var url = parent.Meteor.getSubsUrl();
33 } catch(e) {
34 return false;
35 }
36 if (typeof(url)!="undefined") {
37 pollreq = newXmlHttp();
38 pollreq.onreadystatechange = handleresponse;
39 pollreq.open("GET", url, true);
40 var now = new Date();
41 var t = now.getTime();
42 lastrequesttime = t;
43 if (parent.Meteor.polltimeout) polltimer = setTimeout(ptimeout, parent.Meteor.polltimeout);
44 pollreq.send(null);
45 }
46 }
47
48 function handleresponse() {
49 if (typeof(pollreq) == "object" && pollreq.readyState == 4 && !isaborted) {
50 try {
51 clearTimeout(polltimer);
52 } catch (e) {}
53 try {
54 var y = parent.Meteor.getSubsUrl();
55 } catch (e) { return false };
56 newdata = pollreq.responseText;
57 while (1) {
58 var x = newdata.indexOf("<s"+"cript>");
59 if (x != -1) {
60 y = newdata.indexOf("</"+"script>", x);
61 if (y != -1) {
62 eval(newdata.substring((x+8),y));
63 newdata = newdata.substring(y+9);
64 } else {
65 break;
66 }
67 } else {
68 break;
69 }
70 }
71 if (parent.Meteor.status) {
72 var now = new Date();
73 var t = now.getTime();
74 var x = parent.Meteor.pollfreq - (t-lastrequesttime);
75 if (x < 10) x = 10;
76 pollreq = null;
77 setTimeout(poll, x);
78 }
79 }
80 }
81
82 function ptimeout() {
83 isaborted = 1;
84 pollreq.abort();
85 pollreq = null;
86 clearTimeout(polltimer);
87 var now = new Date();
88 var t = now.getTime();
89 var x = parent.Meteor.pollfreq - (t-lastrequesttime);
90 if (x < 10) x = 10;
91 setTimeout(poll, x);
92 }
93
94 poll();
95
96
97 </script>
98 </body>
99 </html>

  ViewVC Help
Powered by ViewVC 1.1.26