NotARobot
NotARobot

Reputation: 515

Connection to two websockets (via vue-socket.io) in one vue/vuex app

so I have a web application using vue with vuex which has a connection to a websocket via vue-socket-io like this:

Vue.use(new VueSocketIO({
  debug: true,
  connection: SocketIO('http://192.168.0.31:5000'),
  vuex: {
    store,
    actionPrefix: 'SOCKET_',
  },
}));

new Vue({
  router,
  store,
  vuetify,
  render: (h) => h(App),
}).$mount('#app');

My problem is, that besides this websocket, I now need to communicate with yet another server also via websocket. How can I have two websockets with different servers at the same time?

I found a similar question here but I am not sure, if the answer to "just not use vue-socket-io because it won't work" is correct or if there is a way to accomplish this? In this question the user tried to use two stores which I also don't know if it is a food idea?

Thanks for any hint on how I can solve this problem!

Upvotes: 0

Views: 451

Answers (1)

NotARobot
NotARobot

Reputation: 515

Apparently with vuex and the way shown above only one websocket can be connected like this. The only way to connect another on was to locally do it in the components.

Upvotes: 1

Related Questions