Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facepunch Transport - Detect Host losing internet connection #216

Open
WaGi-Coding opened this issue Apr 25, 2023 · 0 comments
Open

Facepunch Transport - Detect Host losing internet connection #216

WaGi-Coding opened this issue Apr 25, 2023 · 0 comments

Comments

@WaGi-Coding
Copy link

WaGi-Coding commented Apr 25, 2023

Hey there, i am using the FacepunchTransport and now i wanted to detect if the host himself lost internet connection and send him back to the main menu if so.

"OnClientDisconnectCallback" does not get called on the host himself when he loses internet.

Thats how i check if the host disconnected for the clients. But how would i do so for the host/server himself?

private void OnClientDisconnectCallback(ulong id) {
    Debug.Log("OnClientDisconnectCallback: " + id.ToString());

    if (IsClient) {
        if (id == 0) { // 0 = host?!
            LobbySaver.instance.currentLobby?.Leave();
            LobbySaver.instance.currentLobby = null;
            NetworkManager.Singleton.Shutdown();

            SceneManager.LoadScene("MainMenu");
        }
    }
}
@WaGi-Coding WaGi-Coding changed the title FacepunchTransport - Detect Host losing internet connection Facepunch Transport - Detect Host losing internet connection Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant