コード例 #1
0
 public Task SendUserDataChangeInfo(UserDataChangeInfo info, CancellationToken cancellationToken)
 {
     return Task.FromResult(true);
 }
コード例 #2
0
        /// <summary>
        /// Sends the user data change info.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public Task SendUserDataChangeInfo(UserDataChangeInfo info, CancellationToken cancellationToken)
        {
            var socket = GetActiveSocket();

            return socket.SendAsync(new WebSocketMessage<UserDataChangeInfo>
            {
                MessageType = "UserDataChanged",
                Data = info

            }, cancellationToken);
        }
コード例 #3
0
        private async Task SendNotifications(IEnumerable<KeyValuePair<Guid, List<IHasUserData>>> changes, CancellationToken cancellationToken)
        {
            foreach (var pair in changes)
            {
                var userId = pair.Key;
                var userSessions = _sessionManager.Sessions
                    .Where(u => u.ContainsUser(userId) && u.SessionController != null && u.IsActive)
                    .ToList();

                if (userSessions.Count > 0)
                {
                    var user = _userManager.GetUserById(userId);

                    var dtoList = pair.Value
                        .DistinctBy(i => i.Id)
                        .Select(i =>
                        {
                            var dto = _userDataManager.GetUserDataDto(i, user);
                            dto.ItemId = i.Id.ToString("N");
                            return dto;
                        })
                        .ToList();

                    var info = new UserDataChangeInfo
                    {
                        UserId = userId.ToString("N"),

                        UserDataList = dtoList
                    };

                    foreach (var userSession in userSessions)
                    {
                        try
                        {
                            await userSession.SessionController.SendUserDataChangeInfo(info, cancellationToken).ConfigureAwait(false);
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorException("Error sending UserDataChanged message", ex);
                        }
                    }
                }

            }
        }
コード例 #4
0
 public Task SendUserDataChangeInfo(UserDataChangeInfo info, CancellationToken cancellationToken)
 {
     // Roku probably won't care about this
     return Task.FromResult(true);
 }
コード例 #5
0
        private async Task SendNotifications(IEnumerable<KeyValuePair<Guid, List<string>>> changes, CancellationToken cancellationToken)
        {
            foreach (var pair in changes)
            {
                var userId = pair.Key;
                var userSessions = _sessionManager.Sessions
                    .Where(u => u.UserId.HasValue && u.UserId.Value == userId && u.SessionController != null && u.IsActive)
                    .ToList();

                if (userSessions.Count > 0)
                {
                    var dtoList = pair.Value
                        .Select(i => _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(userId, i)))
                        .ToList();

                    var info = new UserDataChangeInfo
                    {
                        UserId = userId.ToString("N"),

                        UserDataList = dtoList
                    };

                    foreach (var userSession in userSessions)
                    {
                        try
                        {
                            await userSession.SessionController.SendUserDataChangeInfo(info, cancellationToken).ConfigureAwait(false);
                        }
                        catch (Exception ex)
                        {
                            _logger.ErrorException("Error sending UserDataChanged message", ex);
                        }
                    }
                }

            }
        }
コード例 #6
0
 public Task SendUserDataChangeInfo(UserDataChangeInfo info, CancellationToken cancellationToken)
 {
     // Roku probably won't care about this
     return _cachedTask;
 }