Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

Send queued messages only after session is continued with token? #8

Open
BeayemX opened this issue Jan 12, 2018 · 6 comments
Open

Send queued messages only after session is continued with token? #8

BeayemX opened this issue Jan 12, 2018 · 6 comments
Labels

Comments

@BeayemX
Copy link

BeayemX commented Jan 12, 2018

At the moment when I am disconnected from the server and I call a method I get an error but the method call is queued and executed as soon as a connection to the server is re-established.

But after reconnecting the user isn't logged in any more. Therefore all the method calls will return an error that the user needs to be logged in.

I tried to use the token to resume the session in ddpConnection.OnConnected but this is too late and the user will be logged in after all the queued messages have been executed.

Is there any way to solve this problem?

@brean
Copy link
Collaborator

brean commented Jan 12, 2018

I can't think of a way to do this without some tinkering of the code in this repo.

The first thing that comes to my mind is to add a flag if a DdpAccount is used somewhere and insert the login-call in the first positions of the queue if it is set.

Another, more general way to implement this might be to have dependencies for the MethodCalls so they have a list of functions that need to be executed before the call is executed (and those can e.g. check if the user is logged in and if not call login first and then execute the call again after the dependency-call answered).

@brean brean added the bug label Jan 12, 2018
@green-coder
Copy link
Owner

Hi there and welcome. I remember that I did not do some extensive testing on the re-connection when I wrote the library last year. Now I am focused on some other ecosystem, I won't have time to improve this library unless I suddenly come back to game development, but that's very unlikely. Feel free to contribute modifications to the library.

@BeayemX
Copy link
Author

BeayemX commented Jan 15, 2018

Currently I work around this problem by calling the login-method inside the disconnect-callback. This way it is the first method inside the queue.

@derwaldgeist
Copy link

It's definitely a bug that the library resends all subs and methods right after re-connecting. In general, it is not very well-suited for instable network connections. We tried to improve this in our own fork, but it's pretty tricky. Happy to share our code if someone is interested.

@green-coder
Copy link
Owner

I would be glad to take your PR. For info, I am not longer working with Meteor or Unity and I am no longer using this library.

I moved on to software/web development using Clojure(Script) - a totally different world. Not sure if I will be able to find the time to test your PR, but other users may be happy to have access to it.

@derwaldgeist
Copy link

derwaldgeist commented May 28, 2021

Hey @green-coder Thanks for your fast response. I'm not sure if a PR would work because I also switched the whole library to using BestHTTP instead of the WebSocket library you originally included. This was because I already used BestHTTP in my app and having two WebSocket implementations in one app was just unnecessary. So it's rather a fork with a lot of changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants