示例#1
0
        private async void IsUserIdle(CurrentlyUsedWebPageRepository repo, string connectionId)
        {
            await Task.Delay(_userIdleTime);

            CurrentlyUsedWebPage userTrace = _repo.GetAllWebPages().SingleOrDefault(x => x.ConnectionId == new Guid(connectionId));

            if (userTrace != null)
            {
                _repo.DeletePage(connectionId);
                // blast the inactivity notif
                Update(userTrace, 3);
            }
        }
示例#2
0
        private async void UserDisconnected(CurrentlyUsedWebPage userTrace, CurrentlyUsedWebPageRepository repo, string connectionId)
        {
            // copy userTrace to local var, this gets disposed by CLR after some time.
            var localUserTrace = userTrace;
            await Task.Delay(_userTimeToLive);

            // make sure localtrace isn't null
            if (localUserTrace == null)
            {
                return;
            }

            // check db if a connection still exist
            bool hasUserReconnected = repo.GetAllWebPages().Any(x => x.User == localUserTrace.User &&
                                                                x.Url == localUserTrace.Url && x.ConnectionId != new Guid(connectionId));


            // delete if disconnected
            if (!hasUserReconnected)
            {
                repo.DeletePage(connectionId);
                Update(userTrace, 4);
            }
        }