You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bufferedAmount property is good for your application to control how much messages you can send (to avoid memory overhead), but it works only if you disable perMessageDeflate.
I propose to extend the property by calculating _sender.queue size as well.
Example:
get bufferedAmount () {
var amount = 0;
var senderQueueSize = 0;
if (this._socket) amount = this._socket.bufferSize || 0;
if (this._sender && this._sender.queue) {
for (i = 0; i < this._sender.queue.length; i += 1) {
senderQueueSize += this._sender.queue[i].data.length;
}
}
return amount + senderQueueSize;
}
The best solution is to avoid cycle at all by adding queueSize variable to _sender and add/subtract length when adding a new element to queue.
get bufferedAmount () {
var amount = 0;
var senderQueueSize = 0;
if (this._socket) amount = this._socket.bufferSize || 0;
return amount + this._sender.queueSize;
}
The text was updated successfully, but these errors were encountered:
It makes sense but it's slightly harder as, in some cases, the data to send is converted to a buffer only before writing to the socket. This can probably be fixed though by converting the data to a buffer before it is added to the queue.
The bufferedAmount property is good for your application to control how much messages you can send (to avoid memory overhead), but it works only if you disable perMessageDeflate.
I propose to extend the property by calculating _sender.queue size as well.
Example:
The best solution is to avoid cycle at all by adding queueSize variable to _sender and add/subtract length when adding a new element to queue.
The text was updated successfully, but these errors were encountered: