Esempio n. 1
0
        IEnumerator updateServer(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(ping());
                }
            }
        }
Esempio n. 2
0
        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,
            };

            runner.StartCoroutine(updateServer(partialServer));
        }