Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ActionCableClient.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Pod::Spec.new do |s|

s.source_files = 'Source/Classes/**/*'
s.frameworks = 'Foundation'
s.dependency 'Starscream', '~> 3.0.3'
s.dependency 'Starscream', '~> 3.1'
end
12 changes: 10 additions & 2 deletions Source/Classes/ActionCableClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ open class ActionCableClient {
open var headers : [String: String]? {
get { return socket.request.allHTTPHeaderFields }
set {
for (field, value) in headers ?? [:] {
for (field, value) in newValue ?? [:] {
socket.request.setValue(value, forHTTPHeaderField: field)
}
}
Expand Down Expand Up @@ -349,8 +349,16 @@ extension ActionCableClient {
fileprivate func didDisconnect(_ error: Swift.Error?) {

var attemptReconnect: Bool = true
var rejected: Bool = false
var connectionError: ConnectionError?

if let error = error as? WSError {
if error.type == Starscream.ErrorType.protocolError {
print("ActionCable connection rejected: \(error)")
rejected = true;
}
}

let channels = self.channels
for (_, channel) in channels {
let message = Message(channelName: channel.uid, actionName: nil, messageType: MessageType.hibernateSubscription, data: nil, error: nil)
Expand All @@ -364,7 +372,7 @@ extension ActionCableClient {
}

// Reconcile reconncetion attempt with manual disconnect
attemptReconnect = !manualDisconnectFlag && attemptReconnect
attemptReconnect = !manualDisconnectFlag && attemptReconnect && !rejected

// disconnect() has not been called and error is
// worthy of attempting a reconnect.
Expand Down
2 changes: 1 addition & 1 deletion Source/Classes/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ open class Channel: Hashable, Equatable {
internal var onReceiveActionHooks: Dictionary<String, OnReceiveClosure> = Dictionary()
internal unowned var client: ActionCableClient
internal var actionBuffer: Array<Action> = Array()
open let hashValue: Int = Int(arc4random_uniform(UInt32(Int32.max)))
public let hashValue: Int = Int(arc4random_uniform(UInt32(Int32.max)))
}

public func ==(lhs: Channel, rhs: Channel) -> Bool {
Expand Down