How to connect multiple sockets in a single vuejs project?
allenshaji opened this issue ยท 4 comments
import VueSocketIOExt from 'vue-socket.io-extended';
import { io } from 'socket.io-client';
const socket = io('http://localhost:3200/');
const socket1 = io('http://localhost:3100/');
Vue.use(VueSocketIOExt, socket);
Vue.use(VueSocketIOExt, socket1);
I tried using the above code. But only only socket is working. Is it possible to connect both the sockets simultaneously. Thanks for the help in advance
I don't think this is possible yet.
First, you should not be able to register the same Plugin twice.
Currently, the plugin registers one global property $socket that directly controls the one socket. So you can only have one socket instance at a time managed by the plugin. For multiple sockets, it would need to register an array $sockets for example. So you could access your sockets like $sockets[1]. I could think about many use cases where this could be useful. Interesting idea you supposed ๐๐ฝ
Thanks jnt0r. Is it possible to register array of sockets?
Not yet
Would be interested in this as well. Built a performance monitoring app without realizing i could only connect 1 socket ๐