private void ClientSocket_OnClose(object sender, CloseEventArgs e) { IsConnected = false; serverConnection = null; UnityDispatchQueue.RunOnMainThread(() => { // If the client is Quitting by himself, we don't have to inform him of his disconnection. if (e.Code == (ushort)DisconnectionReason.ClientRequestedDisconnect) { return; } if (e.Code == (ushort)DisconnectionReason.ModVersionMismatch) { string[] versions = e.Reason.Split(';'); InGamePopup.ShowWarning( "Mod Version Mismatch", $"Your Nebula Multiplayer Mod is not the same as the Host version.\nYou:{versions[0]} - Remote:{versions[1]}", "OK", OnDisconnectPopupCloseBeforeGameLoad); return; } if (e.Code == (ushort)DisconnectionReason.GameVersionMismatch) { string[] versions = e.Reason.Split(';'); InGamePopup.ShowWarning( "Game Version Mismatch", $"Your version of the game is not the same as the one used by the Host.\nYou:{versions[0]} - Remote:{versions[1]}", "OK", OnDisconnectPopupCloseBeforeGameLoad); return; } if (SimulatedWorld.IsGameLoaded) { InGamePopup.ShowWarning( "Connection Lost", $"You have been disconnected from the server.\n{e.Reason}", "Quit", () => LocalPlayer.LeaveGame()); } else { InGamePopup.ShowWarning( "Server Unavailable", $"Could not reach the server, please try again later.", "OK", () => { LocalPlayer.IsMasterClient = false; SimulatedWorld.Clear(); DestroySession(); OnDisconnectPopupCloseBeforeGameLoad(); }); } }); }
public void Reconnect() { SimulatedWorld.Clear(); Disconnect(); ConnectInternal(); }
public void Reconnect() { SimulatedWorld.Clear(); Disconnect(); Connect(serverIp, serverPort); }