centrifugal / centrifuge-swift

Swift client SDK for bidirectional real-time communication with Centrifugo and Centrifuge-based server over WebSocket
MIT License
49 stars 44 forks source link

Presence after migration from 0.4.6 -> 0.7.2 #103

Closed swilliams-intellum closed 2 months ago

swilliams-intellum commented 2 months ago

I am using the presence API to receive notifications that the list of present users has changed. As someone became present or absent my completion closure for the subscription.presence method would be called. After upgrading to 0.7.2 this no longer happens. It only gets called initially after first subscribing.

subscription.presence(completion: { result in
            switch result {
            case .success(let presence):
                completion?(presence, nil)

Is this a bug or has the API changed in a way that I need to account for?

Note: the same thing happens on Android.

swilliams-intellum commented 2 months ago

Apologies! It is the onJoin and onLeave that are not being called. I am getting the initially present users in the presence completion handler. Do you think this could be a server config issue? The server does have "presence": true in its config.

FZambia commented 2 months ago

Hello @swilliams-intellum

Yeah, may be the case that server is just not configured to send join/leave events to a channel - just having "presence": true is not enough. For Centrifugo v5 the config can look like https://centrifugal.dev/docs/server/presence#join-and-leave-events .

swilliams-intellum commented 2 months ago

Thanks! That did the trick.