RonJames
RonJames4w ago

realtime.clientID

So i'm using the client id to work out an indexing system for players and am currently looking at reconnecting players who disconnect. I notice when players reconnect to a room. Their client ID stays the same as their previous connection. This is actually very helpful but I want to understand how the client ID works and if it will reliably stay consistent. I'm using this for a webgl project so I need to know this will be consistent behaviour.
3 Replies
kapa.ai
kapa.ai4w ago
Hi @RonJames. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the available documentation, the clientID property in Normcore (accessed via realtime.clientID or room.clientID) represents the local client’s unique identifier for the current session. However, the knowledge sources do not explicitly state that a client will always receive the same clientID after disconnecting and reconnecting to a room, especially in a WebGL context. Here’s what is clear from the documentation: - clientID is assigned by the server and is used to identify clients within a room session. - In offline mode, clientID is always 0 for the local client, but this does not apply to online multiplayer scenarios. - There is no explicit guarantee in the documentation that a client will receive the same clientID after disconnecting and reconnecting. The assignment of clientID is managed by the server, and the documentation does not mention any persistence or session tracking that would ensure the same ID is reassigned to a reconnecting client. - The documentation does not mention any special handling for WebGL clients regarding clientID assignment or persistence. Caution:
If your player indexing or reconnection logic depends on clientID remaining consistent across reconnects, you should be aware that this behavior is not guaranteed by the documented API. For robust player tracking, consider implementing your own user identification system (e.g., using authentication tokens or user IDs) that persists across sessions, rather than relying solely on clientID. Summary:
The knowledge sources do not provide enough information to guarantee that clientID will reliably stay consistent after a disconnect and reconnect. You should not rely on this behavior for critical logic in your application, especially for WebGL or any platform. For more details on the clientID property, see the Room class reference and Realtime class reference. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@378869779668140042> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Mechabit
Mechabit4w ago
it's not guaranteed and will reuse client IDs and will try to use a lower number if possible it's better to use platform user id if you need to reconnect a player to their user data rather than client id

Did you find this page helpful?