public static void EndServer() { if (isOn) { listener.EndServer(); isOn = false; } }
public static void ToggleServer(bool runServer = true) { if (runServer) //Start server { if (isRunning) { try { if (isRunning) { listener.EndServer(); isRunning = false; } } catch (Exception ex) { Debug.Log(ex.ToString()); } } isRunning = true; listener.StartServer(); } else //Stop server { try { if (isRunning) { listener.EndServer(); isRunning = false; } } catch (Exception ex) { Debug.Log(ex.ToString()); } } }