@@ -11,6 +11,7 @@ import {Base64} from '../base/base64.js';
1111'use strict' ;
1212
1313const reconnectionAttempts = 10 ;
14+ const maxSequence = 2147483647 ;
1415
1516// eslint-disable-next-line require-jsdoc
1617function handleResponse ( status , data , resolve , reject ) {
@@ -39,6 +40,7 @@ export class SioSignaling extends EventModule.EventDispatcher {
3940 this . _reconnectTimes = 0 ;
4041 this . _reconnectionTicket = null ;
4142 this . _refreshReconnectionTicket = null ;
43+ this . _messageSequence = 0 ;
4244 }
4345
4446 /**
@@ -69,6 +71,7 @@ export class SioSignaling extends EventModule.EventDispatcher {
6971 data : data ,
7072 } ,
7173 } ) ) ;
74+ this . _incrementMessageSequence ( ) ;
7275 } ) ;
7376 } ) ;
7477 this . _socket . on ( 'reconnecting' , ( ) => {
@@ -102,7 +105,28 @@ export class SioSignaling extends EventModule.EventDispatcher {
102105 data ) => {
103106 if ( status === 'ok' ) {
104107 this . _reconnectTimes = 0 ;
105- this . _onReconnectionTicket ( data ) ;
108+ if ( typeof data === 'object' ) {
109+ if ( Array . isArray ( data . messages ) ) {
110+ let isMissingStart = false ;
111+ for ( const msg of data . messages ) {
112+ if ( isMissingStart ) {
113+ this . dispatchEvent (
114+ new EventModule . MessageEvent ( 'data' , {
115+ message : {
116+ notification : msg . event ,
117+ data : msg . data ,
118+ } ,
119+ } ) ) ;
120+ this . _incrementMessageSequence ( ) ;
121+ } else if ( msg . seq === this . _messageSequence ) {
122+ isMissingStart = true ;
123+ }
124+ }
125+ }
126+ this . _onReconnectionTicket ( data . ticket ) ;
127+ } else {
128+ this . _onReconnectionTicket ( data ) ;
129+ }
106130 } else {
107131 this . dispatchEvent ( new EventModule . OwtEvent ( 'disconnect' ) ) ;
108132 }
@@ -201,4 +225,19 @@ export class SioSignaling extends EventModule.EventDispatcher {
201225 clearTimeout ( this . _refreshReconnectionTicket ) ;
202226 this . _refreshReconnectionTicket = null ;
203227 }
228+
229+ /**
230+ * @function _clearReconnectionTask
231+ * @instance
232+ * @desc Increase the message sequence.
233+ * @memberof Owt.Conference.SioSignaling
234+ * @private .
235+ */
236+ _incrementMessageSequence ( ) {
237+ if ( this . _messageSequence === maxSequence ) {
238+ this . _messageSequence = 0 ;
239+ } else {
240+ this . _messageSequence ++ ;
241+ }
242+ }
204243}
0 commit comments