Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How unique is socket.id?

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. E.g. if user 1 disconnects from the application, user 2 who connects later shouldn't have the same socket.id that user 1 had before even though user 1 is no longer connected. Are socket ids unique for the entire time socket.io is listening to the server?

like image 448
Smitha Avatar asked Jan 07 '14 02:01

Smitha


1 Answers

Assuming that you're using [email protected] (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.

like image 166
robertklep Avatar answered Oct 12 '22 22:10

robertklep