@@ -54,7 +54,8 @@ export default class {
54
54
_channelGroups : Object ;
55
55
_presenceChannelGroups : Object ;
56
56
57
- _timetoken : number ;
57
+ _currentTimetoken : number ;
58
+ _lastTimetoken : number ;
58
59
_region : ?number ;
59
60
60
61
_subscribeCall : ?Object ;
@@ -87,7 +88,9 @@ export default class {
87
88
this . _pendingChannelSubscriptions = [ ] ;
88
89
this . _pendingChannelGroupSubscriptions = [ ] ;
89
90
90
- this . _timetoken = 0 ;
91
+ this . _currentTimetoken = 0 ;
92
+ this . _lastTimetoken = 0 ;
93
+
91
94
this . _subscriptionStatusAnnounced = false ;
92
95
93
96
this . _reconnectionManager = new ReconnectionManager ( { timeEndpoint } ) ;
@@ -115,7 +118,10 @@ export default class {
115
118
return ;
116
119
}
117
120
118
- if ( timetoken ) this . _timetoken = timetoken ;
121
+ if ( timetoken ) {
122
+ this . _lastTimetoken = this . _currentTimetoken ;
123
+ this . _currentTimetoken = timetoken ;
124
+ }
119
125
120
126
channels . forEach ( ( channel : string ) => {
121
127
this . _channels [ channel ] = { state : { } } ;
@@ -152,6 +158,8 @@ export default class {
152
158
this . _leaveEndpoint ( { channels, channelGroups } , ( status ) => {
153
159
status . affectedChannels = channels ;
154
160
status . affectedChannelGroups = channelGroups ;
161
+ status . currentTimetoken = this . _currentTimetoken ;
162
+ status . lastTimetoken = this . _lastTimetoken ;
155
163
this . _listenerManager . announceStatus ( status ) ;
156
164
} ) ;
157
165
}
@@ -161,7 +169,8 @@ export default class {
161
169
Object . keys ( this . _presenceChannels ) . length === 0 &&
162
170
Object . keys ( this . _channelGroups ) . length === 0 &&
163
171
Object . keys ( this . _presenceChannelGroups ) . length === 0 ) {
164
- this . _timetoken = 0 ;
172
+ this . _lastTimetoken = 0 ;
173
+ this . _currentTimetoken = 0 ;
165
174
this . _region = null ;
166
175
this . _reconnectionManager . stopPolling ( ) ;
167
176
}
@@ -258,7 +267,7 @@ export default class {
258
267
const subscribeArgs = {
259
268
channels,
260
269
channelGroups,
261
- timetoken : this . _timetoken ,
270
+ timetoken : this . _currentTimetoken ,
262
271
filterExpression : this . _config . filterExpression ,
263
272
region : this . _region
264
273
} ;
@@ -279,7 +288,9 @@ export default class {
279
288
this . _subscriptionStatusAnnounced = true ;
280
289
let reconnectedAnnounce : StatusAnnouncement = {
281
290
category : categoryConstants . PNReconnectedCategory ,
282
- operation : status . operation
291
+ operation : status . operation ,
292
+ lastTimetoken : this . _lastTimetoken ,
293
+ currentTimetoken : this . _currentTimetoken
283
294
} ;
284
295
this . _listenerManager . announceStatus ( reconnectedAnnounce ) ;
285
296
} ) ;
@@ -292,12 +303,18 @@ export default class {
292
303
return ;
293
304
}
294
305
306
+ this . _lastTimetoken = this . _currentTimetoken ;
307
+ this . _currentTimetoken = payload . metadata . timetoken ;
308
+
309
+
295
310
if ( ! this . _subscriptionStatusAnnounced ) {
296
311
let connectedAnnounce : StatusAnnouncement = { } ;
297
312
connectedAnnounce . category = categoryConstants . PNConnectedCategory ;
298
313
connectedAnnounce . operation = status . operation ;
299
314
connectedAnnounce . affectedChannels = this . _pendingChannelSubscriptions ;
300
315
connectedAnnounce . affectedChannelGroups = this . _pendingChannelGroupSubscriptions ;
316
+ connectedAnnounce . lastTimetoken = this . _lastTimetoken ;
317
+ connectedAnnounce . currentTimetoken = this . _currentTimetoken ;
301
318
this . _subscriptionStatusAnnounced = true ;
302
319
this . _listenerManager . announceStatus ( connectedAnnounce ) ;
303
320
@@ -385,7 +402,6 @@ export default class {
385
402
} ) ;
386
403
387
404
this . _region = payload . metadata . region ;
388
- this . _timetoken = payload . metadata . timetoken ;
389
405
this . _startSubscribeLoop ( ) ;
390
406
}
391
407
0 commit comments