IEnumerator InternalUpdateServer(PartialServerJson server) { // wait to not be sending while (sending) { yield return(new WaitForSeconds(1)); } // We need to check added incase Update is called soon after Add, and add failed if (!added) { Logger.LogWarning("UpdateServer called when before server was added"); yield break; } sending = true; UnityWebRequest request = requestCreator.Patch("servers/" + serverId, server); yield return(requestCreator.SendRequestEnumerator(request, OnSuccess)); sending = false; void OnSuccess(string responseBody) { skipNextPing = true; if (_pingCoroutine == null) { _pingCoroutine = runner.StartCoroutine(InternalPing()); } } }
public void UpdateServer(ServerJson server) { // TODO, use PartialServerJson as Arg Instead if (!added) { Logger.LogWarning("UpdateServer called when before server was added"); return; } PartialServerJson partialServer = new PartialServerJson { displayName = server.displayName, playerCount = server.playerCount, maxPlayerCount = server.maxPlayerCount, customData = server.customData, }; partialServer.Validate(); runner.StartCoroutine(InternalUpdateServer(partialServer)); }