コード例 #1
0
        public async Task DrawLinesAsync(DrawLinesDto drawLinesDto)
        {
            var sender = await userRepository.GetAsync(drawLinesDto.UserId);

            var game = await gameRepository.GetAsync(drawLinesDto.GameId);

            //if (sender.Id != game.DrawerPlayerId)
            //{
            //    await Clients.Caller.SendAsync("Error", new ErrorMessage { Id = "draw-line-error", Message = "Only selected drawer can draw on canvas" });
            //    return;
            //}

            await gameRepository.AddLinesToGameAsync(game.Id, drawLinesDto.Lines);

            var result    = mapper.Map <LinesDtoToSend>(drawLinesDto);
            var groupName = game.Id.ToString();
            await Clients.Group(groupName).SendAsync("DrawLines", result);
        }