strophejs
strophejs copied to clipboard
Strophe.Websocket.prototype._onIdle send redundant packets
Found interesting behavior:
test: I was implementing private chat. After a message is sent, I immediately request an acknowledge packet. This happens to be very fast (chrome dev tools says that they are sent exactly at the same time). Because that, _onIdle
function gets called 2 times, each with the same packets to be sent. In other words, the _onIdle
function does not have enough time to complete and clear queue before next _onIdle
call. This results in redundant packets being sent.
expected: No redundant packets being sent
Possible fix:
~~move this._conn._data = [];
right under var data = this._conn._data;
, so queue gets immediately cleared after a local variable is created.~~
EDIT: (suggested fix was not correct) You need to clear the queue only if status is not paused, so you dont remove unsent stanzas
move this._conn._data = [];
right under if (data.length > 0 && !this._conn.paused) {
line
env: Chrome Version 65.0.3325.181 (Official Build) (64-bit) Using sockets implementation Strophe version: 1.2.14