I have 2 servers A and B. Each running on a different port. How do I connect to both servers in Vuejs using vue-socket.io-extended
?
What I have tried so far is:
import store from './store'
import VueSocketIOExt from 'vue-socket.io-extended'
import io from 'socket.io-client'
Vue.use(VueSocketIOExt, io('http://localhost:4000'), { store })
Vue.use(VueSocketIOExt, io('http://localhost:5000'), { store })
The above code does connect both instances of our vue-socket.io-extended
client to their respective servers, but events and emits only work for the client that was first registered.
The code below is what I have in my VueComponent:
export default {
...
sockets: {
serverA_event(state){
// do something ...
},
serverB_event(state){
// do something ..
}
},
...
}
Note: I would like to use vue-socket.io-extended
to do something similar to what is done in the example here with vue-socket.io
. I tried using vue-socket.io
but for some reason, I couldn't get it to work.