Implemented Polling#doClose

This commit is contained in:
Guillermo Rauch
2012-01-03 12:59:07 -08:00
parent 397ce64e80
commit e398000c0e

View File

@@ -203,11 +203,23 @@ Polling.prototype.write = function (data) {
};
/**
* Writes a payload of messages
* Closes the transport.
*
* @api private
*/
HTTPTransport.prototype.payload = function (msgs) {
this.write(parser.encodePayload(msgs));
Polling.prototype.doClose = function () {
if (this.dataReq) {
debug('aborting ongoing data request');
this.dataReq.abort();
}
if (this.req) {
debug('cleaning up ongoing poll');
this.send({ type: 'close' });
} else {
// upon next poll an error 500 will be emitted
// which is effective at signaling the close
debug('closed polling but no open request - next poll should err');
}
};