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

Add data getter for update token with data #79

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lewan42
Copy link

@lewan42 lewan42 commented Oct 24, 2024

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

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) {
Copy link
Member

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?

Copy link
Author

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(). Отличается только "место хранения" токена.

Copy link
Member

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.

Copy link
Member

@FZambia FZambia Oct 30, 2024

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

Copy link
Author

@lewan42 lewan42 Oct 30, 2024

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

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 this pull request may close these issues.

2 participants