예제 #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);
			}
		}
예제 #2
0
        private void PrompterBroadcastFailed(UserInfo userInfo)
        {
            var group = userInfo.Group;
            var operatorId = group.OperatorId;
            var operatorInfo = IdDictionary[operatorId];
            var groupName = operatorId.ToString();

            Clients.Client(operatorInfo.Connection)
                .prompterDisconnected(userInfo.Id);

            group.PrompterIdList.Remove(userInfo.Id);

            userInfo.Group = null;
            Groups.Remove(userInfo.Connection, groupName);

            if (group.PrompterIdList.Count == 0)
            {
                operatorInfo.Group = null;
                Groups.Remove(operatorInfo.Connection, groupName);
            }
        }
예제 #3
0
        private void CheckBroadcast(UserInfo userInfo)
        {
            var isBroadcasting =
                userInfo != null
                && userInfo.Group != null;

            if (!isBroadcasting)
            {
                return;
            }

            if (userInfo.Role == OperatorRoleName)
            {
                ErrorEndBroadcast();
            }
            else if (userInfo.Role == PrompterRoleName)
            {
                PrompterBroadcastFailed(userInfo);
            }
        }