RoyNexus
RoyNexus4mo ago

Is checking Realtime.clientID == 0 the best way to identify if I'm on offline mode?

I want to use Realtime API to identify if I'm on offline mode. The only way I see in the docs to do this is to check for Realtime.clientID == 0 is this correct? Is there other way to do this without custom code? Docs: https://normcore.io/documentation/room/offline-mode#things-to-know
Offline Mode | Normcore Documenation
Normcore supports connecting to an offline room which can be useful for singleplayer games, tutorials, and other experiences that don't require a connection to the internet.
2 Replies
kapa.ai
kapa.ai4mo ago
Hi @RoyNexus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, you are correct. According to the Normcore documentation (https://normcore.io/documentation/room/offline-mode#things-to-know), in offline mode, Realtime.clientID and Room.clientID will always return 0. This is one way to identify if you're in offline mode. However, there's another way to check if you're in offline mode. When you connect to a room in offline mode, you can check the offlineMode property of the room object. Here's an example:
private void DidConnectToRoom(Realtime realtime) {
if (realtime.room.offlineMode) {
Debug.Log($"Connected to room in offline mode!");
}
}
private void DidConnectToRoom(Realtime realtime) {
if (realtime.room.offlineMode) {
Debug.Log($"Connected to room in offline mode!");
}
}
In this example, realtime.room.offlineMode will be true if you're in offline mode. This might be a more direct way to check if you're in offline mode, as it doesn't rely on the clientID being 0. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@362795742198235136> kapa.ai is still learning and improving, please let us know how it did by reacting below