Gregivy / simpleddp

An easy to use DDP client library
MIT License
165 stars 19 forks source link

subscribe to same publication twice, the seconds one will not work. #11

Closed imhazige closed 5 years ago

imhazige commented 5 years ago

I have tried sub and subscribe, the first time, it will work.

then the seconds time, will never trigger the ready state.

I have used the login plugin.

imhazige commented 5 years ago

first time, it work. image

then logout, login again, sub the seconds time with the same server object.

imhazige commented 5 years ago

the seconds time

image

imhazige commented 5 years ago

I noticed the _nosub, what's that mean?

imhazige commented 5 years ago

@Gregivy please help

Gregivy commented 5 years ago

Hello @imhazige! I was not able to reproduce this error, can you show me the example code, please?

imhazige commented 5 years ago

ok, can you send me your gitlab account, I will add you to the project. my gtalk is imhazige, hope I can connect to you.

Gregivy commented 5 years ago

'_nosub' means that server responded with error or unsubscribed you if its value is true

imhazige commented 5 years ago

the code is connecting to the dev server, which is working for a long time, so I think the server have no problem.

imhazige commented 5 years ago

I have add you to the project, @Gregivy

imhazige commented 5 years ago

https://github.com/imhazige/meteor-ddp-client-test/invitations

I have add the README.md

Gregivy commented 5 years ago

So you manually login, then logout, then login again and subscription does not work. From your logs I see that subscriptionIdis the same in both cases which means that you have not tried to restart the subscription. When you logout the server sends nosub message, so simpleddp stops the subscription but the ddpSubscription object is not destroyed. Next time you login you try to subscribe with the same parameters, simpleddp sees that and does nothing but return you your previous subscription (which is stopped). I think I can improve this behavior and in next simpleddp releases your code will work. For now you should remove your subscription when your home page dies.

imhazige commented 5 years ago

@Gregivy Thanks, I will have a try now, I have tried remove yesterday, still not work. I will try restart.

Gregivy commented 5 years ago

Instead of let userSub = server.subscribe("account.info"); put subscription in some page variable, then use destroyed hook in your home.vue component and do something like this

this.userSub.remove();
this.userSub = null;
imhazige commented 5 years ago

ok

On Sat, Aug 10, 2019 at 9:18 AM Gregivy notifications@github.com wrote:

Instead of let userSub = server.subscribe("account.info"); put subscription in some page variables, then use destroyed hook in your home.vue component and do something like this

this.userSub.remove(); this.userSub = null;

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Gregivy/simpleddp/issues/11?email_source=notifications&email_token=AA7OSFQYL4DBDGIOTYTDHQTQDYJPPA5CNFSM4IKSJ352YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4ADCJA#issuecomment-520106276, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7OSFXRJOSBBWM625O3DMLQDYJPPANCNFSM4IKSJ35Q .

imhazige commented 5 years ago

It works! thank you so much! @Gregivy

Gregivy commented 5 years ago

You are welcome :)