-
Notifications
You must be signed in to change notification settings - Fork 176
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
Propagate code and reason from disconnect from server on client #212
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine. I think it's a good idea to only have one disconnected method and more explicit information is a good idea, since it allows implementers to act on the information.
That said. I can see that a code and reason is good for debug purposes, but anything other than that, would require some form of custom protocol contracts between communicating parties, right?
Yes it feels better to have separate methods. It's necessary to have code and reason to have different behaviors based on the disconnection reason . i believe a physical disconnect will give another code etc. |
0de3f8a
to
f041a38
Compare
I added a separate commit showing how it would look like with separate method for disconnect without params, but I forced pushed the first commit again after reading your post again! So now it is in it's original state. |
We should note that this change has breaking changes to some external APIs, namely:
I don't know how to avoid it. But since it would trigger a major version change on the API, I would either create version 2 branch or welcome any ideas on how to avoid it. |
Would it be better with the commit I did with keeping the parameterless version + add with code / reason? Would it still be considered a breaking change? 0de3f8a |
The fact that they are interfaces will cause the breaking change as long as a new method is added, an existing one is removed or modified. As far as I know, there isn't alot we can do to avoid it |
f041a38
to
9980299
Compare
So what's the verdict on this @TVolden ? :) |
Hi @emilm, |
First off, thank you TVolden for making this library. I’m just wondering what’s the status of this PR? These changes would be helpful. Best regards, |
The PR should target the v2 branch instead of master. That's it, really 🙂 Sincerely |
The reason for this change is to have different reconnect strategies depending on why you are disconnected.
If the OCPP rejected you because of a 404 or something like that, or if you simply lose connection.
My question here is what do do with explicit disconnects from within the code?
Right now I pass 0, "disconnect() method called" - but it looks a bit hacky.
2 other alternatives are:
a separate disconnect method without arguments - but then the implementation must handle 2 disconnect() methods.
nullable Integer so no error code is passed instead of a magic 0 or -1 or something