Пример #1
0
        /// <summary>
        /// Helper method that wraps sending of the Live State update and logging of this action.
        /// </summary>
        private void SendLiveState(int players, int maxPlayers, string serverName, string map, string gameMode, string version)
        {
            LogWithTimestamp(string.Format("Sending <b>Live State</b>: players = {0}, maxPlayers = {1}, " +
                                           "serverName = {2}, map = {3}, gameMode = {4}, version = {5}",
                                           players, maxPlayers, serverName, map, gameMode, version));

            // It is safe to call this every frame if it is easier to do so - the values are only
            // sent to the Agent if they have changed.
            // The final parameter can be used to send additional custom key/value pairs.
            server.SetLiveState(players, maxPlayers, serverName, map, gameMode, version, null);
        }
    private IEnumerator Simulation()
    {
        yield return(new WaitUntil(() => server.Status == OneServerStatus.OneServerStatusReady));

        server.SetApplicationInstanceStatus(OneApplicationInstanceStatus.OneServerOnline);

        while (true)
        {
            server.SetLiveState(UnityEngine.Random.Range(0, 101), 100, "Test", "Test", "Test", "v0.1", null);
            server.SendReverseMetadata("Example map", "Example mode", "example type");

            if (++_stateSentCount % 10000 == 0)
            {
                Debug.LogFormat("State sent messages: {0}", _stateSentCount);
            }

            yield return(null);
        }
    }