-
Notifications
You must be signed in to change notification settings - Fork 57
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
Execute disonnected_callback only when websocket is disconnected #386
Conversation
…econnect attempts when the websocket is already disconnected. This leads to the situation that the time_disconnected of ChargePoint resets on reconnect attempts and therefore the handling of the OfflineThreshold is incorrect. This change only calls disconnected_callback if websocket is not already disconnected. Signed-off-by: pietfried <[email protected]>
Is it possible to have common logic for the different websocket implementations (plain, tls, tpm ...)? Right now this looks a bit like code duplication. |
The current state is intentional as we're slowly moving over from websocket++ (used in _plain and _tls) to libwebsockets (only used for _tpm at the moment). Work on this will be tracked in #387 |
I guess I didn't express myself well, it is not about websocket details leaking into ocpp logic, it is more the other way around. This PR does now 3 times the following:
Of course it is debatable, but I would argue that this should be common logic or code. One could do the |
There is indeed quite some duplicated code in the websocket plain and tls implementations. The refactoring of the websocketpp implementation has so far been postponed because other priorities were set and the switch to libwebsockets was planned anyway. Libwebsockets is to replace websocketpp, so the effort of refactoring the websocketpp impl was avoided so far. |
You're absolutely right, and I think we all agree that this should be refactored soon. I justed wanted to give some context that a proper refactoring is already underway which addresses a few more issues as well 🙂 so any time and effort spent on improving this part of the lib will be more wisely spent there once the PRs are opened |
Without this change, the disconnected_callback was executed also on reconnect attempts when the websocket is already disconnected. This leads to the situation that the time_disconnected of ChargePoint resets on reconnect attempts and therefore the handling of the OfflineThreshold is incorrect. This change only calls disconnected_callback if websocket is not already disconnected.
Fixes TC_B_57_CS