-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
How to prevent connection until authed? #114
Comments
I was tired. I just disabled auto connections and connected the sockets manually. |
Hi, @busheezy Thanks for your issue :) import VueSocketio from 'vue-socket.io-extended';
import io from 'socket.io-client';
const socket = io('http://socketserver.com:1923', {
autoConnect: false
});
Vue.use(VueSocketio, socket);
// when everything is ready to connection (correct page, auth info in store, etc)
socket.open();
// or in components
this.$socket.client.open(); // or `this.$socket.open()` for library version 1.x-3.x more info in official socket.io documentation Let me know is the issue still relevant |
Thanks for everything. |
I have same problem too. Do you ever want to write this scenario on README? e.g. FAQ |
Yeah, I think it's a good idea, @ALiangLiang |
I use options like this
not
i do not know why i use your options is not connect success, |
@xuejiangjun is right. Only the options should be in curly braces. |
Updated original answer. Thanks @xuejiangjun for notice and @LaKing for check. |
Hi, |
Try: then
|
with autoConnect = false |
Hi @dedosmedia What do you think @capndave ? I will update the code here in the meanwhile |
Thanks @dedosmedia ,answer updated |
If you use jwt, with socketio-jwt you can just connect like normal and emit |
What if you can't get the token in the initialization phase using nuxt? When the login is successful, you can't put the token in the parameters of the IO connection |
I have a home page where I'm not using sockets at all. I'm using this with Vuex. Is there a way to prevent the socket from trying to connect on my home page or until it at least has the auth info in my store? There might be something obvious, it's late.
The text was updated successfully, but these errors were encountered: