Add data getter for update token with data#79
Add data getter for update token with data#79lewan42 wants to merge 4 commits intocentrifugal:masterfrom
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.
Token update may be lost in this case or maybe I am not following the code correctly?
There was a problem hiding this comment.
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.
I mean that if getDataGetter is not null, then getConnectionToken won't be called.
There was a problem hiding this comment.
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.
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