Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Process missing messages during reconnection #323

Open
wants to merge 3 commits into
base: 4.2.x
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Process missing messages during reconnection
  • Loading branch information
starwarfan committed Dec 10, 2019
commit 38b7f8db713d6e304e3a9f28f349f77a5a4dba21
22 changes: 21 additions & 1 deletion src/sdk/conference/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class SioSignaling extends EventModule.EventDispatcher {
this._reconnectTimes = 0;
this._reconnectionTicket = null;
this._refreshReconnectionTicket = null;
this._messageSequence = 0;
}

/**
Expand Down Expand Up @@ -69,6 +70,7 @@ export class SioSignaling extends EventModule.EventDispatcher {
data: data,
},
}));
this._messageSequence++;
});
});
this._socket.on('reconnecting', () => {
Expand Down Expand Up @@ -102,7 +104,25 @@ export class SioSignaling extends EventModule.EventDispatcher {
data) => {
if (status === 'ok') {
this._reconnectTimes = 0;
this._onReconnectionTicket(data);
if (typeof data === 'object') {
if (Array.isArray(data.messages)) {
const pendingMessages = data.messages.filter(msg => {
return (msg.seq > this._messageSequence);
});
pendingMessages.forEach(msg => {
this.dispatchEvent(new EventModule.MessageEvent('data', {
message: {
notification: msg.event,
data: msg.data,
},
}));
this._messageSequence++;
});
}
this._onReconnectionTicket(data.ticket);
} else {
this._onReconnectionTicket(data);
}
} else {
this.dispatchEvent(new EventModule.OwtEvent('disconnect'));
}
Expand Down