Mischa Winkler
Mischa Winkler2mo ago

Is it possible that clientID's get re-assigned

If user A leaves a room and other clients join later, is it possible that player A's client ID gets re-assigned? Can I assume that a clientID's won't get re-used for the lifespan of a room? I want to run simple logic that only runs once on the first client that connects to a room: if(realtime.clientID == 0) Init();
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @Mischa Winkler. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The documentation does not provide explicit information on whether a clientID can be reassigned or reused when a client leaves a room and others join later. However, it's important to note that clientID is a property of the Realtime instance, which represents the local client's connection to the room. This suggests that the clientID is likely unique to each client's connection session and may not persist or be reserved if a client disconnects. For running logic that only runs once on the first client that connects to a room, you might want to consider using a different approach. For instance, you could use a model in the datastore to keep track of whether the initialization has been done. This way, the first client to connect could set this value in the datastore, and subsequent clients could check this value before running the initialization. Remember, Normcore model updates are designed to be as bandwidth and CPU efficient as possible, so using the datastore for this purpose should not be a problem. Here are the relevant links for your reference: - Realtime Properties (https://normcore.io/documentation/reference/classes/Normal.Realtime.Realtime) - Are model change events more expensive than RPCs? (https://normcore.io/documentation/room/common-questions#are-model-change-events-more-expensive-than-rpcs) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@847936237003604048> kapa.ai is still learning and improving, please let us know how it did by reacting below
maxweisel
maxweisel2mo ago
clientIDs are re-used. the server keeps them as low as possible to keep it within a byte for bandwidth reasons