Compare commits

...

3 Commits
0.3.7 ... 0.4

Author SHA1 Message Date
Guillermo Rauch
57c8d37d47 Implemented heartbeats 2010-06-26 15:04:55 -07:00
Guillermo Rauch
5e329229b4 Fix for flush in htmlfile 2010-06-25 14:57:57 -07:00
Guillermo Rauch
ea36d24d9e Updated Socket.IO client 2010-06-18 03:02:51 -03:00
3 changed files with 10 additions and 5 deletions

View File

@@ -17,11 +17,11 @@ exports.htmlfile = Client.extend({
'Transfer-Encoding': 'chunked'
});
this.response.write('<html><body>' + new Array(244).join(' '));
this.response.flush();
if ('flush' in this.response) this.response.flush();
this._payload();
this._heartbeatInterval = setInterval(function(){
self.response.write('<!-- heartbeat -->');
self.response.flush();
if ('flush' in self.response) self.response.flush();
}, this.options.heartbeatInterval);
break;
@@ -44,7 +44,7 @@ exports.htmlfile = Client.extend({
_write: function(message){
this.response.write('<script>parent.s._('+ message +', document);</script>');
this.response.flush();
if ('flush' in this.response) this.response.flush();
}
});

View File

@@ -37,9 +37,14 @@ exports.websocket = Client.extend({
this.connection.write(headers.concat('', '').join('\r\n'));
this.connection.addListener('end', function(){ self._onClose(); });
this.connection.addListener('data', function(data){ self._handle(data); });
if (this._proveReception()) {
if (this._proveReception()){
this._payload();
}
setInterval(function(){
self._write(JSON.stringify({heartbeat: '1'}));
}, 10000);
},
_handle: function(data){