-
Notifications
You must be signed in to change notification settings - Fork 5
Send queued messages only after session is continued with token? #8
Comments
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). |
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. |
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. |
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. |
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. |
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. |
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?
The text was updated successfully, but these errors were encountered: