Send update notification to particular users using socket.io

前端 未结 2 1922
梦谈多话
梦谈多话 2021-02-02 04:38

Following is the code on front end, where storeSelUserId contains user_id to send the message-

FYI - Node Version 1.1.0

//          


        
2条回答
  •  一整个雨季
    2021-02-02 04:48

    According to what i understand, you need private notification send to only some users. For that, save your users name to whom you want to send and their corresponding socket in different hashes.

    username [socket.name] = username to be added;
    usersocket [ socket.name ] =socket;
    

    Then to emit the messages to that user only, use

    usersocket[ socket.name ].emit('event for send message', ' what you want to send ');
    

提交回复
热议问题