コード例 #1
0
ファイル: GameHub.cs プロジェクト: winterleitner/lama
        /// <summary>
        /// SignalR endpoint for sending chat messages.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task SendMessage(int game, string message)
        {
            var g = GamesController.FindGame(game);

            if (g is null)
            {
                return;
            }
            var user = await _userManager.GetUserAsync(Context.User);

            var msg = g.AddChatMessage(user, message);
            await Clients.Users(g.Players.Select(p => p.GetUser().Id).ToList()).SendAsync("OnNewChatMessage", msg);
        }