is there a way to count the connections to the room without using the Avatar Manager
I am not using the Avatar manager at all. I would like to count the number clients connected to the room.
7 Replies
Hi @DC. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, there is a way to count the connections to a room without using the Avatar Manager in Normcore. You can use the
Realtime
component to get this information. Here's how you can do it:
1. First, you need to access the Room
object from your Realtime
instance.
2. The Room
class has a property called clientID
which represents the current client's ID.
3. You can use the datastore
property of the Room
to get all the client IDs connected to the room.
Here's a simple example of how you might implement this:
This approach uses the Realtime
and Room
classes, which are core components of Normcore, without relying on the Avatar Manager.
Remember that this method will count all connected clients, including those that might not have instantiated an avatar. If you need to track specific types of connections (e.g., only players with avatars), you might need to implement additional logic.
For more information on the Realtime
and Room
classes, you can refer to the Normcore documentation:
- Realtime
- Room
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1259730396577529917> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
The GetAllClientIDs method does not exist for datastore
There is not, but you can replicate the pattern used by RealtimeAvatarManager in your own code if you'd like
AI making shit up lol
the bot has been pretty good so far but this one was pretty bad lol
I use this pattern a fair bit in all projects, not just normcore projects.
A basic usage could look like this: But for a normcore object you could register/unregister when the realtime model is replaced, so that its initialised at the time of registration. Or if it's a poolable object you could Regsiter/Unregister in OnEnable/OnDisable, etc.
A basic usage could look like this: But for a normcore object you could register/unregister when the realtime model is replaced, so that its initialised at the time of registration. Or if it's a poolable object you could Regsiter/Unregister in OnEnable/OnDisable, etc.