I’m using unity relay and unity lobby in unity 2021.3.3f1 and I would like to automaticelly make him shut down the relay and quit the lobby the player when he doesn’t have wifi anymore.
I already search about that but I didn’t found anything.
I would like to know how can I know when the player is disconnected to make him go to the main menu and be deconnected from relay and lobby ( like he doesn’t have anymore relation with the relay and the lobby ).
But that is for the client as well as for the host, like when the host is disconnected, the lobby is deleted and all the client are kick.
Basically I would just like to know if there is a function to know if the player is disconnected.
Thanks in advance.
You do not need to do anything. When a client disconnects due to loss of connectivity, the client representation in the lobby or game session will eventually time out. The timeout period for the session is set in NetworkManager but should be ample so a several second hiccup doesn‘t force players out.
On the local side, there is nothing you can do anyway since the client does no longer have an active Internet connection.
Locally you just hook into OnClientDisconnected callback and load the menu scene if it‘s the local player that disconnected. Again, this may happen only after a timeout though it may be faster on the local side if there is a total loss of connection.
What about manually disconnecting oneself.
I have an exit button in my game so the player can quit game and return to menu.
I’ve been searching but struggling to find info on a function to disconnect from lobby and relay.
If we integrate lobby with relay, can we just handle any disconnection stuff using lobby logic?