public void TestGetConnectedUserByUserid(int index)
        {
            var hubUsers = AddPreparedUsers();

            var user = _manageHubUser.GetConnectedUserById(hubUsers[index].UserId).FirstOrDefault();

            Assert.Equal(hubUsers[index].UserId, user.UserId);
            Assert.Equal(hubUsers[index].GroupName, user.GroupName);
        }
Example #2
0
        public async void CheckUserDisconnected()
        {
            var repo      = new FakeRepo(_context);
            var fakeUser  = repo.FakeSingleUser();
            var fakeQueue = repo.FakeSingleQueue();

            var connection = MakeHubConnection();

            await connection.StartAsync();

            await connection.InvokeAsync("RegisterDoctor", fakeUser.Id, fakeUser.RoomNo);

            await connection.StopAsync();

            await Task.Delay(5000);

            fakeQueue = _context.Queue.FindByCondition(q => q.Id == fakeQueue.Id).SingleOrDefault();

            bool result         = false;
            var  connectedUsers = _hubUser.GetConnectedUserById(fakeUser.Id);

            if (connectedUsers == null)
            {
                result = true;
            }

            Assert.True(!fakeQueue.IsActive);
            Assert.True(result);
        }
Example #3
0
        public async Task <IActionResult> OnPost(string returnUrl = null)
        {
            var claimIdentity = (ClaimsIdentity)this.User.Identity;
            var claim         = claimIdentity.FindFirst(ClaimTypes.NameIdentifier);

            _queueService.SetQueueInactive(claim.Value);

            var hubUser = _manageHubUser.GetConnectedUserById(claim.Value);

            if (hubUser != null && hubUser.Count() == 1)
            {
                _queueHub.InitGroupScreen(hubUser.FirstOrDefault());
            }

            await _signInManager.SignOutAsync();

            _logger.LogInformation("User logged out.");
            if (returnUrl != null)
            {
                return(LocalRedirect(returnUrl));
            }
            else
            {
                return(Page());
            }
        }
        public IActionResult Logout()
        {
            var claimIdentity = (ClaimsIdentity)this.User.Identity;
            var claim         = claimIdentity.FindFirst(ClaimTypes.NameIdentifier);

            _queueService.SetQueueInactive(claim.Value);

            var hubUser = _manageHubUser.GetConnectedUserById(claim.Value);

            if (hubUser != null && hubUser.Count() == 1)
            {
                _queueHub.InitGroupScreen(hubUser.FirstOrDefault());
            }

            return(Ok());
        }
Example #5
0
        public async override Task OnDisconnectedAsync(Exception exception)
        {
            string connectionId = Context.ConnectionId;
            var    groupMember  = _hubUser.GetUserByConnectionId(connectionId);

            if (exception != null)
            {
                Log.Warning(String.Concat(logPrefix, "Disconnecting user: [ ", connectionId, " ] for room: [ ",
                                          groupMember.GroupName, " ]: \n", exception.Message));
            }
            else
            {
                Log.Information(String.Concat(logPrefix, "Disconnecting user: [ ", connectionId, " ] from room: [ ",
                                              groupMember.GroupName, " ]"));
            }

            await _hubUser.RemoveUserAsync(groupMember);

            await Groups.RemoveFromGroupAsync(connectionId, groupMember.GroupName);

            //if group member changed roomNo exit patient view
            if (groupMember.UserId != null && !_queueService.CheckRoomSubordination(groupMember.UserId, groupMember.GroupName))
            {
                _queueService.SetQueueInactive(groupMember.UserId);
                InitGroupScreen(groupMember);
            }
            else if (groupMember.UserId != null)
            {
                await Task.Delay(TimeSpan.FromMinutes(SettingsHandler.ApplicationSettings.PatientViewNotificationAfterDoctorDisconnectedDelay));

                if (_hubUser.GetConnectedUserById(groupMember.UserId) == null)
                {
                    _queueService.SetQueueInactive(groupMember.UserId);
                    Log.Information(String.Concat(logPrefix, "Room: [ ", groupMember.GroupName, " ] master disconnected, connectionId: [ ",
                                                  groupMember.ConnectionId, " ] userId: [ ", groupMember.UserId, " ]"));
                    InitGroupScreen(groupMember);
                }
            }
            await base.OnDisconnectedAsync(exception);
        }