vue-socket.io-extended
vue-socket.io-extended copied to clipboard
Socket.io namespace support
The only other library (vue-websocket) that claims to have websocket support I can't get to work.
Adding this feature would be awesome, though I imagine it wouldn't be trivial.
Thanks for your issue @jhpratt. I will check how namespaces can be implemented
@probil Here is pull request which implements this feature: https://github.com/MetinSeylan/Vue-Socket.io/pull/98 I hope this helps.
Thanks @mateuszlewko . I will check it out
has there been any progress on supporting multiple socket namespaces?
Here is an idea how it can be done currently https://github.com/probil/vue-socket.io-extended/issues/245#issuecomment-473088995
https://github.com/probil/vue-socket.io-extended/issues/245#issuecomment-473088995 did not work for me. Note that I am using namespaced modules where each module corresponds to a socket.io namespace and I use a plugin to register each module with something like this:
function namespace_plugin (nsp) {
return store => {
const socket = io(nsp)
store.registerModule(nsp, create_namespaced_module(socket))
Vue.use(VueSocketio, socket, { store })
}
}
I pass the io.Socket
instance into the module creation function so it can be stored in the state
and components corresponding to the socket.io namespace can emit
directly to the socket.io namespace on the server since we can't use this.$socket
(?).
Anyway, the first module I register works fine but the second does not; i.e. the SOCKET_EVENT
's in the first module are being listened to but those in the second module are not.
Any idea why this is happening? Thanks!
Edit: note the second module's events are not caught even with a unique mutationPrefix
I used the option presented in #245 but the truth is that it didn't work. Just listen to the events of the first socket. Already the second one is lost
@runegame @gitavi Thanks for your feedback We need proper solution for that problem :)
The other implementation added this recently: https://github.com/MetinSeylan/Vue-Socket.io/pull/207#
Hey, are there any news/updates about the issue with socket.io namespaces?
This is still issue after years. Had to switch to a self-coded Vue binding for socket.io-client
because of this.
You would need to use different name when extending the Vue prototype and use named sockets in decorators etc.
@alza54 can you tell me how you do that?
+1