Esempio n. 1
0
        /// <summary>
        /// gRPC client is thread-safe
        /// </summary>
        public async Task PlayerConnect(string id)
        {
            await _agonesSdk.Alpha().PlayerConnectAsync(id);

            // experimental
            if (await _agonesSdk.Alpha().IsPlayerConnectedAsync(id))
            {
                Console.WriteLine($"{id} is connected");
            }
        }
Esempio n. 2
0
        public async Task SetPlayerCapacity_Sends_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.SetPlayerCapacityAsync(It.IsAny <Count>(), It.IsAny <Metadata>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())).Returns(fakeCall);
            mockSdk.alpha.client = mockClient.Object;

            var result = await mockSdk.Alpha().SetPlayerCapacityAsync(1);

            Assert.AreEqual(expected, result.StatusCode);
        }
Esempio n. 3
0
        public async Task PlayerDisconnect_Sends_OK()
        {
            var mockClient = new Mock <SDK.SDKClient>();
            var mockSdk    = new AgonesSDK();
            var expected   = new Bool()
            {
                Bool_ = true
            };
            var fakeCall = TestCalls.AsyncUnaryCall(Task.FromResult(expected), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { });

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

            var result = await mockSdk.Alpha().PlayerDisconnectAsync("test");

            Assert.AreEqual(expected.Bool_, result);
        }
Esempio n. 4
0
        public async Task GetConnectedPlayers_Sends_OK()
        {
            var mockClient = new Mock <SDK.SDKClient>();
            var mockSdk    = new AgonesSDK();
            var expected   = new List <string> {
                "player1", "player2"
            };
            var playerList = new PlayerIDList()
            {
                List = { expected }
            };
            var fakeCall = TestCalls.AsyncUnaryCall(Task.FromResult(playerList), Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { });

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

            var result = await mockSdk.Alpha().GetConnectedPlayersAsync();

            CollectionAssert.AreEquivalent(expected, result);
        }