예제 #1
0
        private async Task RunCheck(CancellationToken ct)
        {
            while (true)
            {
                if (ct.IsCancellationRequested)
                {
                    throw new OperationCanceledException();
                }

                await Task.Delay(15000, ct).ConfigureAwait(false);

                var playerCount = await _agonesSdk.Alpha().GetPlayerCountAsync();

                if (playerCount <= 0)
                {
                    await _agonesSdk.ShutDownAsync();

                    return;
                }
                // experimental
                var playerIds = await _agonesSdk.Alpha().GetConnectedPlayersAsync();

                Console.WriteLine($"Number of players: {playerIds.Count}");
            }
        }
예제 #2
0
        public async Task Shutdown_Returns_OK()
        {
            var mockClient = new Mock <SDK.SDKClient>();
            var mockSdk    = new AgonesSDK();
            var expected   = StatusCode.OK;
            var fakeCall   = TestCalls.AsyncUnaryCall(Task.FromResult(new Empty()), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { });

            mockClient.Setup(m => m.ShutdownAsync(It.IsAny <Empty>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall);
            mockSdk.client = mockClient.Object;

            var result = await mockSdk.ShutDownAsync();

            Assert.AreEqual(expected, result.StatusCode);
        }