Skip to content

Commit

Permalink
Merge pull request #11 from ahbou/ahbou/fix-missing-channel-name
Browse files Browse the repository at this point in the history
Set message identifier on subscription events
  • Loading branch information
nerzh authored Oct 7, 2022
2 parents 128815e + 4059093 commit f3dfd6f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Sources/ActionCableSwift/ACSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@ public class ACSerializer {
guard
let dict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
else { fatalError(ACError.badDictionaryData.description) }

let messageType = checkResponseType(dict)
switch messageType {
case .confirmSubscription, .rejectSubscription, .cancelSubscription, .hibernateSubscription:
return ACMessage(type: messageType)
case .confirmSubscription,
.rejectSubscription,
.cancelSubscription,
.hibernateSubscription:
var message = ACMessage(type: messageType)
if let identifier = dict["identifier"] as? String {
message.identifier = identifier.toDictionary()
}
return message
case .welcome, .ping:
return ACMessage(type: messageType)
case .message, .unrecognized:
Expand Down

0 comments on commit f3dfd6f

Please sign in to comment.