Skip to content
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

Check if the ocppj client is connected? #154

Closed
sbindzau opened this issue Oct 28, 2022 · 3 comments · Fixed by #156
Closed

Check if the ocppj client is connected? #154

sbindzau opened this issue Oct 28, 2022 · 3 comments · Fixed by #156

Comments

@sbindzau
Copy link

By adding handlers for disconnect and reconnect I can find out and store whether or not the client is connected to the server, but wouldn't it be easier if I could ask the client for that information?

If I create the wsClient and give it to the client at creation, I can keep it and check that with wsClient.IsConnected(), but that breaks the encapsulation in an ugly way, IMO.

Is there another way to do it, or wouldn't it be nice to have a IsConnected()-function on the client (just sending the question on to endpoint/wsClient)?

@lorenzodonini
Copy link
Owner

In my mind, disconnection/reconnection are events that you wish to be notified by, so you don't have to actively poll.
But such a getter can definitely be added. Would you expect to invoke that function from the top level (instead of from the wsClient)?

@sbindzau
Copy link
Author

sbindzau commented Nov 1, 2022

Yes, exactly, I'd prefer a top level function to check the connection. Looking at internal objects seems a bit "unsafe" to me.

The state is not to be polled constantly, but some charger behaviour will be different when offline, so I need to keep track of the connection status.

@lorenzodonini lorenzodonini linked a pull request Nov 16, 2022 that will close this issue
@lorenzodonini
Copy link
Owner

I added the suggested accessor method. Feel free to have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants