There are use cases where it's important to access existing channel instances. While it's possible to keep a local reference of joined channels, it would be safer and less error-prone for apps to be able to access a Socket's channels array directly.
Specific issue:
Note: this PR only allows clients using SwiftPhoenixClient to put in place a workaround, it doesn't actually fix what I believe is a bug.
This week I encountered a scenario in which a locally kept list of channels would get out of sync with the one kept by the Socket even without an obvious user error:
A channel is removed from the local array when a Push returned from Channel.leave() receives an "ok" status
The app attempts to leave a channel while offline
The Channel can't push events without an active internet connection, so it's never officially closed
Unfortunately, Channel.leave() triggers an automatic success if canPush is false. This leads the app to believe that a channel was left successfully.
Context:
There are use cases where it's important to access existing channel instances. While it's possible to keep a local reference of joined channels, it would be safer and less error-prone for apps to be able to access a
Socket
'schannels
array directly.Specific issue:
Note: this PR only allows clients using
SwiftPhoenixClient
to put in place a workaround, it doesn't actually fix what I believe is a bug.This week I encountered a scenario in which a locally kept list of channels would get out of sync with the one kept by the
Socket
even without an obvious user error:Push
returned fromChannel.leave()
receives an "ok" statusChannel
can't push events without an active internet connection, so it's never officially closedChannel.leave()
triggers an automatic success ifcanPush
is false. This leads the app to believe that a channel was left successfully.