Socket.io custom client ID

后端 未结 11 868
栀梦
栀梦 2020-12-04 07:59

I\'m making a chat app with socket.io, and I\'d like to use my custom client id, instead of the default ones (8411473621394412707, 1120516437992682114

11条回答
  •  鱼传尺愫
    2020-12-04 08:34

    or you can override the socket id, like this:

    io.on('connection', function(socket){
    
          socket.id = "YOUR_CUSTOM_ID";
    });
    

    you can see under the array:

    io.sockets.sockets

提交回复
热议问题