Socket.io socket.broadcast.to not working

前端 未结 2 433
面向向阳花
面向向阳花 2021-01-15 10:27

I have in my Express server

userbase = {\'Fitz\': \'84Iw3MNEIMaed0GoAAAD\'}; //Exapmle user to receive message and associated socket id



//S         


        
2条回答
  •  春和景丽
    2021-01-15 10:58

    Do you have users join a namespace on connection?

    socket.join(userbase[data_from_client.to_user]); //'84Iw3MNEIMaed0GoAAAD'
    

    You can try:

    socket.in(userbase[data_from_client.to_user]).emit('get_msg', {msg:data_server.msg});
    

提交回复
热议问题