outstore
outstore

Reputation: 11

Node js Socket.io : How to avoid multiple user connections

I'm working on a node.js + socket.io project and I wanted to know how I could prevent my users to identify themselves several times with the same login.

In fact, I want to disconnect a user who is already connected if this user attempts to sign in with the same account.

Do you have an idea ?

Upvotes: 0

Views: 832

Answers (1)

Andi N. Dirgantara
Andi N. Dirgantara

Reputation: 2051

When a user connected, force him/ her to fulfill some authentication, so each of your socket connection has an identifier. With that identifier, you can search is there any user logged in with same identity? If yes, force to disconnect.

Upvotes: 1

Related Questions