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); } }
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); } }
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); } }