Get the client id of the message sender in socket.io?

前端 未结 2 1741
盖世英雄少女心
盖世英雄少女心 2021-02-07 16:19

on the server side i got

socket.on(\'chat\', function (data) {
    io.sockets.socket(data.clientid).emit(\'chat\', {
        msg: data.msg,
        senderid : se         


        
2条回答
  •  囚心锁ツ
    2021-02-07 16:30

    I'd suggest sending over a username (make sure it's unique) and keeping an object of client ids associated with usernames in memory.

提交回复
热议问题