예제 #1
0
        public Task StartSinglePlayerGameAsync(string gameName, string playerName)
        {
            var command = new StartSinglePlayerGameCommand
            {
                PlayerName = playerName
            };

            return(_client.SendJsonAsync(HttpMethod.Post, $"/api/game/{gameName}/start", command));
        }
예제 #2
0
        public static async Task StartSinglePlayerGame(
            [HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "game/{gameName}/start")] StartSinglePlayerGameCommand command,
            [DurableClient] IDurableEntityClient client,
            [SignalR(HubName = "ponies")] IAsyncCollector <SignalRGroupAction> signalRGroupActions,
            string gameName)
        {
            await signalRGroupActions.AddAsync(new SignalRGroupAction
            {
                UserId    = command.PlayerName,
                GroupName = gameName,
                Action    = GroupAction.Add
            });

            var entityId = new EntityId(nameof(GameSession), gameName);
            await client.SignalEntityAsync <IGameSession>(entityId, proxy => proxy.StartSinglePlayer(command.PlayerName));
        }