How unique is socket.id?

后端 未结 2 1440
暖寄归人
暖寄归人 2021-01-12 02:23

I\'m building an application where I\'d like a unique identifier for every connection for the duration that the app is running and I\'m wondering if socket.id works for this

2条回答
  •  忘掉有多难
    2021-01-12 02:47

    Assuming that you're using socket.io@0.9.x (which is the present version in NPM), the code that generates a new id for each connection/client can be found here.

    I think that you can safely assume that each socket id is going to be unique.

提交回复
热议问题