probil / vue-socket.io-extended

:v::zap: Socket.io bindings for Vue.js and Vuex (inspired by Vue-Socket.io)
MIT License
628 stars 38 forks source link

Cannot receive any room message from server #517

Closed tapornanan closed 3 years ago

tapornanan commented 3 years ago

I have nuxt setup with the vuex store and use userId as a room name.

$socket.emit('joinRoomByUserId', user.id) // import from socket-instance.js

Then later in my server I emit message back to client this.socket.in(userId).emit('GAME_RESULT', 'some message');

But my mutation does not receive any message from SOCKET_GAME_RESULT

I already test on https://amritb.github.io/socketio-client-tool/v1 and it work.

I am not sure what I did wrong on my nuxt project.

PS. also I have the others mutations which listen on the broadcast event feed which is work fine. So the only thing that does not work is receive message specificlly by the room name

probil commented 3 years ago

Hi @tapornanan There are a lot of moving parts and it's really hard to guess what's wrong without seeing the code of both BE and FE parts

I will take a look if create a repo reproducing the issue. Could you do that please?

tapornanan commented 3 years ago

Thank for your response @probil Here is a repo https://github.com/tapornanan/nest-nuxt-socketio

tapornanan commented 3 years ago

I am not sure why code above is working but not in my actual project. :(

tapornanan commented 3 years ago

It was me who emit the joinRoom event inside the middleware which it run on the server side of the nuxt. Moving this code out to execute somewhere on client side solve the problems. 🥂

Thank you

probil commented 3 years ago

you are welcome @tapornanan It's so nice when the issue closes it self. :)