webSocketServer node.js how to differentiate clients

后端 未结 10 2019
[愿得一人]
[愿得一人] 2020-12-22 19:36

I am trying to use sockets with node.js, I succeded but I don\'t know how to differentiate clients in my code. The part concerning sockets is this:

var WebSo         


        
10条回答
  •  一整个雨季
    2020-12-22 20:40

    I'm using fd from the ws object. It should be unique per client.

    var clientID = ws._socket._handle.fd;
    

    I get a different number when I open a new browser tab.

    The first ws had 11, the next had 12.

提交回复
热议问题