Presumably, you will call a web method every time a user enters or leaves a room, right? Thus, you can simply update the number of users in the room at this moment (make sure that you have made the appropriate lock), and if he is 22, call any code that you want (since you are already on the server). You may also need to periodically request users on the server so that you know that they are still active, so that you can remove them from the room if they are disconnected or something else.
source
share