Exemple #1
0
        public async override Task OnConnectedAsync()
        {
            var connectionId = this.Context.ConnectionId;

            Log.Information(String.Concat(logPrefix, "New hub client [ ", connectionId, " ]"));
            var hubUsers = _hubUser.GetConnectedUsersCount("12");

            Log.Debug($"Hub Users Count: {hubUsers}");

            try
            {
                await base.OnConnectedAsync();
            }
            catch (Exception ex)
            {
                Log.Error(String.Concat("Connecting user [ ", connectionId, " ] :", ex.Message));
            }
        }
Exemple #2
0
        public async Task RegisterMultipleDoctors(int reps)
        {
            string roomNo    = "12";
            var    repo      = new FakeRepo(_context);
            var    fakeUsers = repo.FakeMultipleUsers(reps, roomNo);

            var fakeQueues = repo.FakeMultipleQueues(fakeUsers);
            List <WebApp.Models.Queue> expectedQueues = _mapper.Map <List <WebApp.Models.Queue> >(fakeQueues);

            var connection = MakeHubConnection();

            MakeDoctorFullNameReceive(connection);
            MakeQueueNoReceive(connection);
            MakeQueueAdditionalMessageReceive(connection);
            MakeNotifyQueueOccupied(connection);

            await connection.StartAsync();

            int occupiedMsgCount   = 0;
            int queueMsgMatchCount = 0;

            for (int i = 0; i < fakeUsers.Count; i++)
            {
                await connection.InvokeAsync("RegisterDoctor", fakeUsers[i].Id, fakeUsers[i].RoomNo);

                if (!String.IsNullOrEmpty(HubResponse.ReceiveQueueOccupied))
                {
                    occupiedMsgCount++;
                    HubResponse.ReceiveQueueOccupied = String.Empty;
                }
                if (HubResponse.ReceiveQueueNo.Equals(expectedQueues[i].QueueNoMessage))
                {
                    queueMsgMatchCount++;
                    HubResponse.ReceiveQueueNo = String.Empty;
                }
            }

            Assert.Equal(reps - 1, occupiedMsgCount);
            Assert.Equal(reps - 1, _hubUser.GetWaitingUsersCount(roomNo));
            Assert.Equal(1, _hubUser.GetConnectedUsersCount(roomNo));
        }