/[meteor]/googlecode.com/svn/trunk/public_html/stream.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

Annotation of /googlecode.com/svn/trunk/public_html/stream.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 64 - (hide annotations)
Mon Jan 19 11:19:41 2009 UTC (15 years, 3 months ago) by andrew.betts
File MIME type: text/html
File size: 1922 byte(s)
Release 1.06.04 as documented in Google Group

1 andrew.betts 9 <html>
2     <body>
3     <script type="text/javascript">
4     window.onError = null;
5     var domainparts = document.domain.split(".");
6     document.domain = domainparts[domainparts.length-2]+"."+domainparts[domainparts.length-1];
7     parent.Meteor.register(this);
8     var streamreq;
9     var byteoffset;
10 andrew.betts 55 var newdata;
11 andrew.betts 9
12     function abort() {
13     streamreq.abort();
14     }
15    
16     function newXmlHttp() {
17 andrew.betts 62 var xhr = null;
18     try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
19     try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
20     try { xhr = new XMLHttpRequest(); } catch(e) { return false }
21     }
22     }
23     return xhr;
24 andrew.betts 9 }
25    
26     function startstream() {
27     streamreq = newXmlHttp();
28     byteoffset = 0;
29 andrew.betts 55 newdata = "";
30 andrew.betts 32 var url = parent.Meteor.getSubsUrl();
31 andrew.betts 9 streamreq.open("GET", url, true);
32 andrew.betts 32 streamreq.onreadystatechange = function() {
33     if (typeof streamreq == "undefined") return;
34     if (streamreq.readyState == 3) {
35 andrew.betts 55 extractEvents(streamreq.responseText);
36 andrew.betts 32 } else if (streamreq.readyState == 4) {
37 andrew.betts 55 extractEvents(streamreq.responseText);
38 andrew.betts 32 delete streamreq;
39     if (typeof(r)=="function") {
40     r();
41     }
42 andrew.betts 9 }
43     }
44 andrew.betts 32 streamreq.send(null);
45 andrew.betts 62 parent.Meteor.lastrequest = parent.Meteor.time();
46 andrew.betts 9 }
47    
48 andrew.betts 55 function extractEvents(responsestr) {
49     newdata += responsestr.substring(byteoffset);
50     byteoffset = responsestr.length;
51     while (1) {
52     var x = newdata.indexOf("<s"+"cript>");
53     if (x != -1) {
54     y = newdata.indexOf("</"+"script>", x);
55     if (y != -1) {
56     eval(newdata.substring((x+8),y));
57 andrew.betts 61 if (typeof newdata == 'undefined') break; // If message was eof() then we're now in a freed script
58 andrew.betts 55 newdata = newdata.substring(y+9);
59     } else {
60 andrew.betts 32
61 andrew.betts 55 // Last message is incomplete. Ignore it and it will be processed next time
62     break;
63     }
64     } else {
65 andrew.betts 32
66 andrew.betts 55 // No more messages
67     break;
68     }
69     }
70     }
71    
72 andrew.betts 64 window.onload = function() {
73     if (parent.Meteor.status == 4) startstream();
74     }
75 andrew.betts 9 </script>
76     </body>
77 andrew.betts 3 </html>

  ViewVC Help
Powered by ViewVC 1.1.26