コード例 #1
0
ファイル: HubblPlayer.cs プロジェクト: mesenev/hubbl
        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);
        }
コード例 #2
0
ファイル: MobileSession.cs プロジェクト: mesenev/hubbl
        public MobileSession(NetworkSettings settings)
        {
            _settings = settings;

            _user = new HubblUser
            {
                Id = Guid.NewGuid().ToString(),
                Title = "staff"
            };
            _playlist = new ObservableCollection<PlaylistEntry>();
        }
コード例 #3
0
ファイル: ConsoleSession.cs プロジェクト: mesenev/hubbl
 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
     };
 }
コード例 #4
0
ファイル: HubblPlayer.cs プロジェクト: mesenev/hubbl
        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;
        }
コード例 #5
0
ファイル: EchoMessage.cs プロジェクト: mesenev/hubbl
 public EchoMessage(HubblUser sender)
 {
     Sender = sender;
 }
コード例 #6
0
ファイル: HelloMessage.cs プロジェクト: mesenev/hubbl
 public HelloMessage(HubblUser user)
 {
     Sender = user;
 }
コード例 #7
0
ファイル: VkApiService.cs プロジェクト: mesenev/hubbl
		public VkApiService (HubblUser u)
		{
			this._user = u;
		}