@@ -343,12 +343,7 @@ import NWWebSocket
343
343
}
344
344
}
345
345
346
- /**
347
- Set the connection state to disconnected, mark channels as unsubscribed,
348
- reset connection-related state to initial state, and initiate reconnect
349
- process
350
- */
351
- private func resetConnectionAndAttemptReconnect( ) {
346
+ internal func resetConnection( ) {
352
347
if connectionState != . disconnected {
353
348
updateConnectionState ( to: . disconnected)
354
349
}
@@ -362,7 +357,16 @@ import NWWebSocket
362
357
socketConnected = false
363
358
connectionEstablishedMessageReceived = false
364
359
socketId = nil
365
-
360
+ }
361
+
362
+ /**
363
+ Set the connection state to disconnected, mark channels as unsubscribed,
364
+ reset connection-related state to initial state, and initiate reconnect
365
+ process
366
+ */
367
+ private func resetConnectionAndAttemptReconnect( ) {
368
+ resetConnection ( )
369
+
366
370
guard !intentionalDisconnect else {
367
371
return
368
372
}
@@ -463,7 +467,7 @@ import NWWebSocket
463
467
}
464
468
}
465
469
}
466
-
470
+
467
471
let subscriptionEvent = event. copy ( withEventName: Constants . Events. Pusher. subscriptionSucceeded)
468
472
callGlobalCallbacks ( event: subscriptionEvent)
469
473
chan. handleEvent ( event: subscriptionEvent)
@@ -553,21 +557,21 @@ import NWWebSocket
553
557
Logger . shared. debug ( for: . unableToRemoveMemberFromChannel)
554
558
}
555
559
}
556
-
560
+
557
561
/**
558
562
Handle subscription count event
559
-
563
+
560
564
- parameter event: The event to be processed
561
565
*/
562
-
566
+
563
567
private func handleSubscriptionCountEvent( event: PusherEvent ) {
564
568
guard let channelName = event. channelName,
565
569
let channel = self . channels. find ( name: channelName) ,
566
570
let subscriptionCountData = event. dataToJSONObject ( ) as? [ String : Any ] ,
567
571
let count = subscriptionCountData [ Constants . JSONKeys. subscriptionCount] as? Int else {
568
572
return
569
573
}
570
-
574
+
571
575
channel. updateSubscriptionCount ( count: count)
572
576
}
573
577
@@ -628,7 +632,7 @@ import NWWebSocket
628
632
629
633
case Constants . Events. PusherInternal. memberRemoved:
630
634
handleMemberRemovedEvent ( event: event)
631
-
635
+
632
636
case Constants . Events. PusherInternal. subscriptionCount:
633
637
handleSubscriptionCountEvent ( event: event)
634
638
@@ -652,14 +656,14 @@ import NWWebSocket
652
656
}
653
657
654
658
/**
655
- Uses the appropriate authentication method to authenticate subscriptions to private and
659
+ Uses the appropriate authorization method to authorize subscriptions to private and
656
660
presence channels
657
661
658
- - parameter channel: The PusherChannel to authenticate
659
- - parameter auth: A PusherAuth value if subscription is being made to an
660
- authenticated channel without using the default auth methods
662
+ - parameter channel: The PusherChannel to authorize
663
+ - parameter auth: A PusherAuth value if subscription is being made to a
664
+ channel without using the default authorization method
661
665
662
- - returns: A Bool indicating whether or not the authentication request was made
666
+ - returns: A Bool indicating whether or not the authorization request was made
663
667
successfully
664
668
*/
665
669
private func authorize( _ channel: PusherChannel , auth: PusherAuth ? = nil ) -> Bool {
0 commit comments