/// <summary> /// Starts the server with the dependencies this singleton needs. This should only ever be called once, /// as it will throw an exception if it get called again. /// </summary> public static void Start(IUnityServer server) { if (instance == null) { instance = new GameServer(server); for (var i = 0; i < maxStartRetries; i++) { instance.SelectPort(); if (Instance.server.StartServer()) { instance.Register(); return; } } Stop(); throw new Exception(string.Format("Error starting server after {0} retries", maxStartRetries)); } throw new Exception(string.Format("{0} Can only be started once!", typeof(GameServer).FullName)); }