Toggle on/off network connectivity
Is there an easy config to toggle on/off connectivity to mock offline/online transitions on editor?
4 Replies
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, Normcore provides an easy way to toggle between online and offline modes, which can be useful for mocking offline/online transitions in the Unity editor. This is done through the "Offline Mode" feature.
Here's how you can implement it:
1. First, make sure to uncheck "Join Room on Start" on the Realtime component in the Unity inspector if you're going to manually call
Connect()
.
2. Then, you can use the ConnectOptions
struct when calling Connect()
on your Realtime instance. The offlineMode
boolean in this struct allows you to toggle between online and offline modes.
Here's an example of how to implement this:
You can easily toggle between online and offline modes by changing the offlineMode
boolean in the ConnectOptions
.
It's important to note that in offline mode, some behaviors are different:
- Realtime.clientID
and Room.clientID
will always return 0
.
- Realtime.roomTime
and Room.time
will return the device's system time.
- The datastore state of an offline room is cleared upon calling Disconnect()
.
For more details on offline mode and its limitations, you can refer to the Room > Offline Mode documentation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@362795742198235136> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
I'm aware of that option, but I was thinking more towards simulating a lost network connection while playing online
if you're on quest you can just take your headset off for a minute and you'll get timed out by the server