diff --git a/ActionCableSwift.podspec b/ActionCableSwift.podspec index b193649..e8ef5bb 100644 --- a/ActionCableSwift.podspec +++ b/ActionCableSwift.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.name = 'ActionCableSwift' s.module_name = 'ActionCableSwift' - s.version = '0.1.5' + s.version = '0.2.0' s.summary = '🏰 Action Cable Swift is a client library being released for Action Cable Rails 5 which makes it easy to add real-time features to your app.' s.swift_version = '5.1' diff --git a/Sources/ActionCableSwift/ACChannel.swift b/Sources/ActionCableSwift/ACChannel.swift index 82f2712..ed637af 100644 --- a/Sources/ActionCableSwift/ACChannel.swift +++ b/Sources/ActionCableSwift/ACChannel.swift @@ -90,14 +90,14 @@ public class ACChannel { } } - private func send(actionName: String, params: [String: Any] = [:], _ completion: (() -> Void)? = nil) { + private func send(actionName: String, data: [String: Any] = [:], _ completion: (() -> Void)? = nil) { channelSerialQueue.async { [weak self] in guard let self = self else { return } do { let data: Data = try ACSerializer.requestFrom(command: .message, - channelName: self.channelName, action: actionName, - data: params) + identifier: self.identifier, + data: data) self.client?.send(data: data) { completion?() } } catch { fatalError(error.localizedDescription) @@ -107,10 +107,10 @@ public class ACChannel { private func setupAutoSubscribe() { if options.autoSubscribe { - if client?.isConnected ?? false { try? subscribe(params: subscriptionParams) } + if client?.isConnected ?? false { try? subscribe() } client?.addOnConnected { [weak self] (headers) in guard let self = self else { return } - try? self.subscribe(params: self.subscriptionParams) + try? self.subscribe() } } } diff --git a/Sources/ActionCableSwift/ACSerializer.swift b/Sources/ActionCableSwift/ACSerializer.swift index dba7e07..a78e504 100644 --- a/Sources/ActionCableSwift/ACSerializer.swift +++ b/Sources/ActionCableSwift/ACSerializer.swift @@ -13,7 +13,7 @@ public class ACSerializer { public class func requestFrom(command: ACCommand, action: String? = nil, identifier: [String: Any], - data: [String: Any] + data: [String: Any] = [:] ) throws -> String { try makeRequestDictionary(command: command, action: action, @@ -25,7 +25,7 @@ public class ACSerializer { public class func requestFrom(command: ACCommand, action: String? = nil, identifier: [String: Any], - data: [String: Any] + data: [String: Any] = [:] ) throws -> Data { try makeRequestDictionary(command: command, action: action, diff --git a/Sources/ActionCableSwift/ActionCableSwift.swift b/Sources/ActionCableSwift/ActionCableSwift.swift index 12de866..ca74cdd 100644 --- a/Sources/ActionCableSwift/ActionCableSwift.swift +++ b/Sources/ActionCableSwift/ActionCableSwift.swift @@ -88,8 +88,8 @@ public final class ACClient { } @discardableResult - public func makeChannel(name: String, subscriptionParams: [String: Any] = [:], options: ACChannelOptions? = nil) -> ACChannel { - channels[name] = ACChannel(channelName: name, client: self, subscriptionParams: subscriptionParams, options: options) + public func makeChannel(name: String, identifier: [String: Any] = [:], options: ACChannelOptions? = nil) -> ACChannel { + channels[name] = ACChannel(channelName: name, client: self, identifier: identifier, options: options) return channels[name]! }