vue-socket.io-extended icon indicating copy to clipboard operation
vue-socket.io-extended copied to clipboard

Socket.io namespace support

Open jhpratt opened this issue 6 years ago • 13 comments

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.

jhpratt avatar Jun 02 '18 05:06 jhpratt

Thanks for your issue @jhpratt. I will check how namespaces can be implemented

probil avatar Jun 04 '18 13:06 probil

@probil Here is pull request which implements this feature: https://github.com/MetinSeylan/Vue-Socket.io/pull/98 I hope this helps.

mateuszlewko avatar Jul 04 '18 01:07 mateuszlewko

Thanks @mateuszlewko . I will check it out

probil avatar Jul 04 '18 09:07 probil

has there been any progress on supporting multiple socket namespaces?

Nocturem avatar Oct 31 '18 07:10 Nocturem

Here is an idea how it can be done currently https://github.com/probil/vue-socket.io-extended/issues/245#issuecomment-473088995

probil avatar Mar 14 '19 22:03 probil

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

databasedav avatar Mar 15 '19 21:03 databasedav

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 avatar Apr 26 '19 18:04 runegame

@runegame @gitavi Thanks for your feedback We need proper solution for that problem :)

probil avatar Apr 26 '19 22:04 probil

The other implementation added this recently: https://github.com/MetinSeylan/Vue-Socket.io/pull/207#

databasedav avatar May 17 '19 23:05 databasedav

Hey, are there any news/updates about the issue with socket.io namespaces?

5knnbdwm avatar Jan 27 '21 14:01 5knnbdwm

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 avatar Feb 14 '21 19:02 alza54

@alza54 can you tell me how you do that?

JAGFx avatar Jun 18 '21 05:06 JAGFx

+1

tarzansarka avatar Jun 18 '21 16:06 tarzansarka