Closed loongmxbt closed 3 years ago
Hey @loongmxbt 👋
Rooms are supported but there is a difference how you use it on the BE. The syntax you use in Vuex actions is correct.
But according to the docs, you need to trigger events on io
(not on socket
) in order to send message to all room participant:
// sends message to all room member
io.to(roomId).emit('roomInfo', {
action: 'join'
});
// sends message to all room members excluding the current client
// that's why you don't receive it (!)
socket.to(roomId).emit('roomInfo', {
action: 'join'
});
Could you confirm that it solves your problem?
Thank you very much! Changing socket.to
into io.to
solves the problem! I need to watch the docs more carefully.
I've stuck here for several time and hope someone can help. I've seen some related issues but still can't figure out how. https://github.com/probil/vue-socket.io-extended/issues/517 https://github.com/probil/vue-socket.io-extended/issues/455
Server
Client Vuex
Only
socket_test
can receive data,socket_roomInfo
andsocket_message
cannot receive data. When I modify serversocket.to(
${roomId}).emit('roomInfo')
intosocket.emit('roomInfo')
, then I can receive data on client.So my question is, how can I receive
roomInfo
event data on client vuex?