public void DislikeTrack(HubblUser user, int entryId) { foreach (var userMarkedId in _usersMarkedByEntryId[entryId]) if (userMarkedId == user.Id) return; _usersMarkedByEntryId[entryId].Add(user.Id); UpdateUserPriorities(); if (!_usersActivities.ContainsKey(user.Id)) { var newActivity = new UserActivitiesRecord { basePriority = 1.0, activitiesCount = 0, lastActivityTime = DateTime.Now }; _usersActivities.Add(user.Id, newActivity); } var activitiesRecord = _usersActivities[user.Id]; if (activitiesRecord.activitiesCount++ == 0) ++_activeUsersCount; var entry = _playlistEntries[entryId]; ++entry.DislikesNum; entry.Priority *= (_activeUsersCount - 1.0)/_activeUsersCount; Playlist.Sort(comparePlaylistEntries); }
public MobileSession(NetworkSettings settings) { _settings = settings; _user = new HubblUser { Id = Guid.NewGuid().ToString(), Title = "staff" }; _playlist = new ObservableCollection<PlaylistEntry>(); }
public ConsoleSession(NetworkSettings settings, IMusicPlayer player) { _player = player; var interfaces = NetworkInterface.GetAllNetworkInterfaces(); _settings = settings; _user = new HubblUser { Id = interfaces.First().Id, Title = Environment.MachineName, IsHub = true, Hub = Environment.MachineName }; }
public PlaylistEntry QueueTrack(HubblUser user, Track track) { UpdateUserPriorities(); if (!_usersActivities.ContainsKey(user.Id)) { var newActivity = new UserActivitiesRecord { basePriority = 1.0, activitiesCount = 0, lastActivityTime = DateTime.Now }; _usersActivities.Add(user.Id, newActivity); } var activitiesRecord = _usersActivities[user.Id]; if (activitiesRecord.activitiesCount++ == 0) ++_activeUsersCount; var entry = new PlaylistEntry { User = user, Track = track, Id = _freeEntryId++, LikesNum = 0, DislikesNum = 0, Priority = activitiesRecord.basePriority }; activitiesRecord.basePriority *= Math.Pow(0.5, track.Duration.TotalMilliseconds/AVG_TRACK_LENGTH_MS); _usersMarkedByEntryId.Add(entry.Id, new List<string>()); _usersMarkedByEntryId[entry.Id].Add(user.Id); Playlist.Add(entry); Playlist.Sort(comparePlaylistEntries); _playlistEntries.Add(entry); if (!_playing) Play(); return entry; }
public EchoMessage(HubblUser sender) { Sender = sender; }
public HelloMessage(HubblUser user) { Sender = user; }
public VkApiService (HubblUser u) { this._user = u; }