Example #1
0
        public void LogOn()
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            var identity = (FormsIdentity)HttpContext.Current.User.Identity;

            var id         = _cookieParser.GetUserId(identity);
            var role       = _cookieParser.GetUserRoleName(identity);
            var connection = Context.ConnectionId;

            var userInfo = new UserInfo
            {
                Id         = id,
                Role       = role,
                Connection = connection
            };

            IdDictionary[id] = userInfo;
            ConnectionDictionary[connection] = userInfo;

            if (role == PrompterRoleName)
            {
                PrompterStatus.ChangeStatus(id, On);
            }
        }
Example #2
0
        public void FetchSuccess(int operatorId)
        {
            var id = ConnectionDictionary[Context.ConnectionId].Id;

            PrompterStatus.ChangeStatus(id, Busy);

            var operatorInfo = IdDictionary[operatorId];

            Clients.Client(operatorInfo.Connection).prompterConnected(id);
        }
Example #3
0
        public void LogOff()
        {
            var      connection = Context.ConnectionId;
            UserInfo userInfo;

            if (!ConnectionDictionary.TryGetValue(connection, out userInfo))
            {
                return;
            }

            CheckBroadcast(userInfo);
            userInfo.Connection = null;
            ConnectionDictionary.TryRemove(connection, out userInfo);
            PrompterStatus.ChangeStatus(userInfo.Id, Off);
        }
Example #4
0
        private void EndBroadcast(bool withError)
        {
            var connection   = Context.ConnectionId;
            var operatorInfo = ConnectionDictionary[connection];
            var id           = operatorInfo.Id;

            var canBroadcast =
                VerifyBusyOperator(id) &&
                VerifyBusyPrompters(id, operatorInfo.Group.PrompterIdList);

            if (!canBroadcast)
            {
                return;
            }

            var idList    = operatorInfo.Group.PrompterIdList;
            var groupName = id.ToString();

            Groups.Remove(connection, groupName);
            operatorInfo.Group = null;

            foreach (var prompterId in idList)
            {
                var userInfo = IdDictionary[prompterId];

                Groups.Remove(userInfo.Connection, groupName);
                userInfo.Group = null;
                PrompterStatus.ChangeStatus(prompterId, On);
                if (withError)
                {
                    Clients.Client(userInfo.Connection).operatorDisconnected();
                }
                else
                {
                    Clients.Client(userInfo.Connection).broadcastEnd();
                }
            }
        }