-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make client status public #29
Conversation
(Also removed some trailing whitespaces as my editor automatically does so on save) |
@danqing hello! Thanks for pr, I have some concerns about this. First, could you describe how you are going to use this? This method can be pretty racy - the connection can be in If your use case is valid then maybe we can introduce a client method |
What I want to achieve is basically what all chat apps have: let the user know when the server is disconnected. For example, if you use FB messenger, you will see a "reconnecting" banner coming up in this case. I want to do the same: when there is connection issue, show a yellow "reconnecting" banner or a red "no connection" banner, and dismiss the banner when connection resumes. So I need to:
|
Btw, this is related to #16 that I opened a while ago. It's useful to know initial connection error too. |
So in summary, I'd like to know at any given time the status of the client:
I also want to understand better potential errors for subscription: if I have the permission and connection is successful, does that guarantee that subscription will succeed? If not, what's an example of failed subscription when connection itself is successful? Thanks! |
To implement what you need you have to track status changes with |
Well, why should I (i.e. the user) track status changes instead of the library itself? I'd say it's a common thing to do, so wouldn't it be better if the library already does this out of the box? |
Please post a code example on how you are planning to use public status without using connect and disconnect events. Maybe I am missing sth. |
As I mentioned, I'd like to show a banner on func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if centrifuge.status == .disconnected {
// show banner
}
} Of course I can track the status myself, but it'd be better if centrifuge already does this. |
The reason why I don't want to make status public at this moment is because now it differs through client implementations. At moment internal statuses are:
While the public API is pretty much the same at this moment. I'd like to keep all clients consistent, so if you write code in one client it could be easily translated to another. So if we make this part public we should carefully think on what other libraries do and make experience consistent. This is pretty big work so I prefer to avoid this at this moment until this is really necessary. Every change makes project maintenance harder, hope you can understand this. |
Fair enough. |
Closes #27. This allows users to know the current status of the client.