onDrain method
void
onDrain()
Called on drain
event
@api private
Implementation
void onDrain() {
writeBuffer.removeRange(0, prevBufferLen);
// setting prevBufferLen = 0 is very important
// for example, when upgrading, upgrade packet is sent over,
// and a nonzero prevBufferLen could cause problems on `drain`
prevBufferLen = 0;
if (writeBuffer.isEmpty) {
emit('drain');
} else {
flush();
}
}