A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pusher/pusher-websocket-swift/commit/98a7b20252f3316982f78911c30c23053b5703cf below:

Deduplicate resetConnection code to ensure consistency in both paths … · pusher/pusher-websocket-swift@98a7b20 · GitHub

File tree Expand file treeCollapse file tree 9 files changed

+30

-37

lines changed

Filter options

Expand file treeCollapse file tree 9 files changed

+30

-37

lines changed Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

Pod::Spec.new do |s|

2 2

s.name = 'PusherSwift'

3 -

s.version = '10.1.1'

3 +

s.version = '10.1.2'

4 4

s.summary = 'A Pusher client library in Swift'

5 5

s.homepage = 'https://github.com/pusher/pusher-websocket-swift'

6 6

s.license = 'MIT'

Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

Pod::Spec.new do |s|

2 2

s.name = 'PusherSwiftWithEncryption'

3 -

s.version = '10.1.1'

3 +

s.version = '10.1.2'

4 4

s.summary = 'A Pusher client library in Swift that supports encrypted channels'

5 5

s.homepage = 'https://github.com/pusher/pusher-websocket-swift'

6 6

s.license = 'MIT'

Original file line number Diff line number Diff line change

@@ -50,18 +50,7 @@ extension PusherConnection: WebSocketConnectionDelegate {

50 50

public func webSocketDidDisconnect(connection: WebSocketConnection,

51 51

closeCode: NWProtocolWebSocket.CloseCode,

52 52

reason: Data?) {

53 -

// Handles setting channel subscriptions to unsubscribed whether disconnection

54 -

// is intentional or not

55 -

if connectionState == .disconnecting || connectionState == .connected {

56 -

for (_, channel) in self.channels.channels {

57 -

channel.subscribed = false

58 -

}

59 -

}

60 - 61 -

self.connectionEstablishedMessageReceived = false

62 -

self.socketConnected = false

63 - 64 -

updateConnectionState(to: .disconnected)

53 +

resetConnection()

65 54 66 55

guard !intentionalDisconnect else {

67 56

Logger.shared.debug(for: .intentionalDisconnection)

Original file line number Diff line number Diff line change

@@ -15,7 +15,7 @@

15 15

<key>CFBundlePackageType</key>

16 16

<string>FMWK</string>

17 17

<key>CFBundleShortVersionString</key>

18 -

<string>10.1.1</string>

18 +

<string>10.1.2</string>

19 19

<key>CFBundleSignature</key>

20 20

<string>????</string>

21 21

<key>CFBundleVersion</key>

Original file line number Diff line number Diff line change

@@ -2,7 +2,7 @@ import Foundation

2 2

import NWWebSocket

3 3 4 4

let PROTOCOL = 7

5 -

let VERSION = "10.1.1"

5 +

let VERSION = "10.1.2"

6 6

// swiftlint:disable:next identifier_name

7 7

let CLIENT_NAME = "pusher-websocket-swift"

8 8 Original file line number Diff line number Diff line change

@@ -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 {

Original file line number Diff line number Diff line change

@@ -15,7 +15,7 @@

15 15

<key>CFBundlePackageType</key>

16 16

<string>BNDL</string>

17 17

<key>CFBundleShortVersionString</key>

18 -

<string>10.1.1</string>

18 +

<string>10.1.2</string>

19 19

<key>CFBundleSignature</key>

20 20

<string>????</string>

21 21

<key>CFBundleVersion</key>

Original file line number Diff line number Diff line change

@@ -2,7 +2,7 @@ import XCTest

2 2 3 3

@testable import PusherSwift

4 4 5 -

let VERSION = "10.1.1"

5 +

let VERSION = "10.1.2"

6 6 7 7

class ClientInitializationTests: XCTestCase {

8 8

private var key: String!

Original file line number Diff line number Diff line change

@@ -138,7 +138,6 @@ class PusherTopLevelApiTests: XCTestCase {

138 138 139 139

let chan = pusher.subscribe(TestObjects.Event.testChannelName)

140 140

connectionDelegate.registerCallback(connectionState: ConnectionState.disconnected) {

141 -

XCTAssertFalse(chan.subscribed)

142 141

disconnected.fulfill()

143 142

}

144 143

@@ -150,6 +149,7 @@ class PusherTopLevelApiTests: XCTestCase {

150 149 151 150

pusher.connect()

152 151

waitForExpectations(timeout: 0.5)

152 +

XCTAssertFalse(chan.subscribed)

153 153

}

154 154 155 155

/* subscribing to channels when already connected */

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4