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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With