mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Merge pull request #421 from TutoringAustralasia/manual_buffer_flushing
Adding support for manual buffer flushing
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
, 'sync disconnect on unload': true
|
||||
, 'auto connect': true
|
||||
, 'flash policy port': 10843
|
||||
, 'manualFlush': false
|
||||
};
|
||||
|
||||
io.util.merge(this.options, options);
|
||||
@@ -311,11 +312,25 @@
|
||||
this.doBuffer = v;
|
||||
|
||||
if (!v && this.connected && this.buffer.length) {
|
||||
this.transport.payload(this.buffer);
|
||||
this.buffer = [];
|
||||
if (!this.options['manualFlush']) {
|
||||
this.flushBuffer();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Flushes the buffer data over the wire.
|
||||
* To be invoked manually when 'manualFlush' is set to true.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Socket.prototype.flushBuffer = function() {
|
||||
this.transport.payload(this.buffer);
|
||||
this.buffer = [];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Disconnect the established connect.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user