File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,16 @@ <h1>
100100 subscription . on ( subscription . events . notification , function ( msg ) {
101101 cb ( msg . body ) ;
102102 } ) ;
103+ subscription . on ( subscription . events . renewError , function ( ) {
104+ subscription . reset ( ) ;
105+ subscription = null ;
106+ getPresenceSubscription ( event , cb ) ;
107+ } ) ;
108+ subscription . on ( subscription . events . subscribeError , function ( ) {
109+ subscription . reset ( ) ;
110+ subscription = null ;
111+ getPresenceSubscription ( event , cb ) ;
112+ } ) ;
103113
104114 subscription
105115 . restore ( [ event ] )
Original file line number Diff line number Diff line change @@ -212,7 +212,8 @@ Subscription.prototype.subscribe = function() {
212212 } . bind ( this ) ) . catch ( function ( e ) {
213213
214214 e = this . _platform . client ( ) . makeError ( e ) ;
215-
215+ // `reset` will remove pubnub instance.
216+ // so if network is broken for a long time, pubnub will be removed. And client can not receive notification anymore.
216217 this . reset ( )
217218 . emit ( this . events . subscribeError , e ) ;
218219
@@ -251,7 +252,8 @@ Subscription.prototype.renew = function() {
251252 } . bind ( this ) ) . catch ( function ( e ) {
252253
253254 e = this . _platform . client ( ) . makeError ( e ) ;
254-
255+ // `reset` will remove pubnub instance.
256+ // so if network is broken for a long time, pubnub will be removed. And client can not receive notification anymore.
255257 this . reset ( )
256258 . emit ( this . events . renewError , e ) ;
257259
@@ -450,6 +452,7 @@ Subscription.prototype._subscribeAtPubnub = function() {
450452
451453 this . _pubnub = new PubNub ( {
452454 ssl : true ,
455+ restore : true ,
453456 subscribeKey : deliveryMode . subscriberKey
454457 } ) ;
455458
You can’t perform that action at this time.
0 commit comments