Пример #1
0
        /// <summary>
        /// Reserve(seconds) will move the GameServer into the Reserved state for the specified number of seconds (0 is forever),
        /// and then it will be moved back to Ready state. While in Reserved state,
        /// the GameServer will not be deleted on scale down or Fleet update, and also it could not be Allocated using GameServerAllocation.
        /// </summary>
        /// <param name="seconds">Amount of seconds to reserve.</param>
        /// <returns>gRPC Status of the request</returns>
        public async Task <Status> ReserveAsync(long seconds)
        {
            try
            {
                await client.ReserveAsync(new Duration { Seconds = seconds },
                                          deadline : DateTime.UtcNow.AddSeconds(RequestTimeoutSec),
                                          cancellationToken : ctoken);

                return(new Status(StatusCode.OK, $"Reserve({seconds}) request successful."));
            }
            catch (RpcException ex)
            {
                LogError(ex, "Unable to mark the GameServer to 'Reserved' state.");
                return(ex.Status);
            }
        }
Пример #2
0
        /// <summary>
        /// Reserve(seconds) will move the GameServer into the Reserved state for the specified number of seconds (0 is forever),
        /// and then it will be moved back to Ready state. While in Reserved state,
        /// the GameServer will not be deleted on scale down or Fleet update, and also it could not be Allocated using GameServerAllocation.
        /// </summary>
        /// <param name="seconds">Amount of seconds to reserve.</param>
        /// <returns>gRPC Status of the request</returns>
        public async Task <Status> ReserveAsync(long seconds)
        {
            try
            {
                await client.ReserveAsync(new Duration()
                {
                    Seconds = seconds
                }, deadline : DateTime.UtcNow.AddSeconds(RequestTimeout), cancellationToken : ctoken);

                return(new Status(StatusCode.OK, $"Reserve({seconds}) request successful."));
            }
            catch (RpcException ex)
            {
                Console.Error.WriteLine(ex.Message);
                return(ex.Status);
            }
        }