Player Joined Room Callbacks
I'm looking to leverage a callback which gets raised when a player connects to a room which calls on all clients. I use the avatar manager callbacks for this but in this context there is no avatar manager. Are there any realtime callbacks for this?
3 Replies
Hi @RonJames. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Normcore’s Realtime API provides the didConnectToRoom event, but this event is only fired locally when your own client connects to a room—not when other clients join. The RealtimeAvatarManager’s avatarCreated/Destroyed events are the standard way to detect when other players join or leave, but as you mentioned, you’re not using the avatar system in this context.
Based on the available documentation, there is no built-in Realtime event or callback that is automatically raised on all clients when any player joins the room, outside of the avatar system. The Realtime API does not provide a direct "player joined" callback that is broadcast to all clients.
If you need to detect when other clients join the room without using avatars, you would need to implement your own mechanism. A common approach is to use a synchronized collection (such as a RealtimeSet or StringKeyDictionary) in the datastore to track connected players. Each client adds itself to the collection on join, and you can listen for changes to this collection to detect when new players join or leave. This approach is mentioned in the context of collections in the datastore documentation, but not shown as a built-in callback for player joins specifically Room Datastore.
In summary:
- There is no built-in Realtime callback for "player joined" that is raised on all clients outside of the avatar system. - You can implement this functionality yourself using a synchronized collection in the datastore and listening for changes. If you need an example or further guidance on implementing this pattern, let me know! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
- There is no built-in Realtime callback for "player joined" that is raised on all clients outside of the avatar system. - You can implement this functionality yourself using a synchronized collection in the datastore and listening for changes. If you need an example or further guidance on implementing this pattern, let me know! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@378869779668140042> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
The source code for realtime avatar manager is included. it could be worth copying that technique.