Skip to content

Delegate method subscribedToChannel not called when subscribed to private channel #446

@yu840915

Description

@yu840915

Currently, subscribedToChannel is called only when receiving the pusher_internal:subscription_succeeded with data
When subscribing to private channel, the event comes without data, so it won't pass this and notify the delegate

guard event.data != nil else {
Logger.shared.debug(for: .subscriptionSucceededNoDataInPayload)
return
}

But that was not the case 8 yr ago,

chan.subscribed = true
if let eData = json["data"] as? String {
callGlobalCallbacks(forEvent: "pusher:subscription_succeeded", jsonObject: json)
chan.handleEvent(name: "pusher:subscription_succeeded", data: eData)
}
if PusherChannelType.isPresenceChannel(name: channelName) {
if let presChan = self.channels.find(name: channelName) as? PusherPresenceChannel {
if let data = json["data"] as? String, let dataJSON = getPusherEventJSON(from: data) {
if let presenceData = dataJSON["presence"] as? [String : AnyObject],
let presenceHash = presenceData["hash"] as? [String : AnyObject] {
presChan.addExistingMembers(memberHash: presenceHash)
}
}
}
}
self.delegate?.subscribedToChannel?(name: channelName)
while chan.unsentEvents.count > 0 {
if let pusherEvent = chan.unsentEvents.popLast() {
chan.trigger(eventName: pusherEvent.name, data: pusherEvent.data)
}
}

subscribedToChannel was called regardless whether the event comes with data.

Can we restore this behavior? Like calling subscribedToChannel before return on else branch of the guard clause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions