-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add data getter for update token with data #79
base: master
Are you sure you want to change the base?
Conversation
this.opts.getTokenGetter().getConnectionToken(connectionTokenEvent, (err, token) -> this.executor.submit(() -> { | ||
if (Client.this.getState() != ClientState.CONNECTING) { | ||
if (this.refreshRequired) { | ||
if (this.data == null && this.opts.getDataGetter() != null) { |
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.
Token update may be lost in this case or maybe I am not following the code correctly?
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.
Sorry about the long delayed response. I think that it can't lost, because the logic is identical if the authorization token was set through the setToken()
method. Only the “place of transfer” of the token is different.
Извините за долгий ответ. Я не думаю, что токен может быть потерян, потому что логика идентична, если бы мы записали токен через метод setToken()
. Отличается только "место хранения" токена.
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.
I mean that if getDataGetter
is not null, then getConnectionToken
won't be called.
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.
And another concern - data callback should be called every time if set during connection opening, see how it was implemented here as an example - https://github.com/centrifugal/centrifuge-dart/pull/88/files
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.
I mean that if getDataGetter is not null, then getConnectionToken won't be called.
that's right, then getConnectionData will be called and inside it you will need to update the token (exactly the same as in getConnectionToken)
And another concern - data callback should be called every time if set during connection opening, see how it was implemented here as an example
I need some time to think. I still don’t understand where I should fix this
Since in other project for the client (JS where I noticed this) there is a token update via a dataGetter and on the project I am working on this was also necessary, I added a new ConnectionDataGetter which will be called if the access token passed via data is expired. I hope this will help others too