w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Socket.io limit number of users

You have to implement your own logic. However, you can count numbers of clients in a room by this:

io.sockets.clients('room')

This will return an array of Socket instances of all clients in the room. Check if the length of this array is greater or less than 2. If a new client wants to join a room which already has 2 client then you can easily prevent him from doing this. Hope this would work for you.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.