//Auto Provisioning private void OnNewPortalFound(object sender, ApplicationEndpointSettingsDiscoveredEventArgs args) { string entityUri = args.ApplicationEndpointSettings.OwnerUri; // The endpoint created is not a matchmaker, verify the endpoint created has been provisioned as an Acdportal _configuration.PortalConfigurations.ForEach(delegate(AcdPortalConfiguration pConfig) { if (SipUriCompare.Equals(entityUri, pConfig.Uri)) { lock (_syncRoot) { if (_acdPlatformState < AcdPlatformState.Terminating) { AcdPortal portal = new AcdPortal(this, pConfig, args.ApplicationEndpointSettings); _portals.Add(portal); _logger.Log(String.Format("AcdPlatform Added AcdPortal {0} to the cache ", entityUri)); portal.BeginStartUp(this.OnPortalStartUpComplete, portal); _logger.Log(String.Format("AcdPlatform Starting AcdPortal {0}", entityUri)); } } return; } }); }
private void HandleIncomingInstantMessagingCalls(object sender, CallReceivedEventArgs <InstantMessagingCall> args) { if (_matchMakerState == MatchMakerState.Started) { AcdSupervisorSession supervisorSession = null; Configuration.Supervisors.ForEach(sup => { if (SipUriCompare.Equals(sup.SignInAddress, args.RemoteParticipant.Uri)) { supervisorSession = new AcdSupervisorSession(this, sup, _logger); supervisorSession.StateChanged += this.OnSupervisorSessionStateChanged; lock (_syncRoot) { _sessions.Add(supervisorSession); } supervisorSession.HandleSupervisorInitialCall(args.Call); return; } }); if (null == supervisorSession) { args.Call.Decline(); } } else { args.Call.Decline(); } }
private void OnAnonymousSubscriberUriChanged(object sender, AcdPlatformAnonymousSubscriberUriChangedEventArgs args) { if (!SipUriCompare.Equals(args.AnonymousSubscriberUri, _anonymousSubscriberUri)) { lock (_syncRoot) { this.UpdatePresenceRelationshipWithAnonymousSubsriber(args.AnonymousSubscriberUri, _anonymousSubscriberUri); _anonymousSubscriberUri = args.AnonymousSubscriberUri; } } }
/// <summary> /// LookupAgent returns the Agent corresponding to the SIP URI supplied in parameter /// </summary> /// <param name="sipUri"> SIP URI of the Agent </param> /// <returns></returns> internal Agent LookupAgent(string sipUri) { // Enumerate all the agents and attempt to find a match. foreach (Agent agent in _configuration.Agents) { if (SipUriCompare.Equals(sipUri, agent.SignInAddress)) { return(agent); } } return(null); }
public override bool Equals(object obj) { Agent agent = obj as Agent; if (agent == null) { return(false); } if (!SipUriCompare.Equals(this.SignInAddress, agent.SignInAddress)) { return(false); } return(true); }
private void OnMatchMakerFound(object sender, ApplicationEndpointSettingsDiscoveredEventArgs args) { string entityUri = args.ApplicationEndpointSettings.OwnerUri; if (SipUriCompare.Equals(entityUri, _acdPlatform._matchMakerConfiguration.Uri)) { _acdPlatform._logger.Log(String.Format("AcdPlatform new AcdAgentMatchMaker found for contact uri {0}, display name {1}", entityUri, args.ApplicationEndpointSettings.OwnerDisplayName)); if (_acdPlatform._acdPlatformState != AcdPlatformState.Terminating && _acdPlatform._acdPlatformState != AcdPlatformState.Terminated) { _acdPlatform._matchMaker = new AcdAgentMatchMaker(_acdPlatform, _acdPlatform._matchMakerConfiguration, args.ApplicationEndpointSettings, _acdPlatform._logger); _acdPlatform._matchMaker.BeginStartup(this.OnMatchMakerStartUpComplete, _acdPlatform._matchMaker); } } }
internal bool AuthorizeParticipant(string participantUri) { SipUriParser parser; if (SipUriParser.TryParse(participantUri, out parser)) { lock (_syncRoot) { _listOfAuthorizedParticipants.Add(participantUri); } List <ConversationParticipant> listOfLobbyParticipants = new List <ConversationParticipant>(_conversation.GetLobbyParticipants()); listOfLobbyParticipants.ForEach(cp => { if (SipUriCompare.Equals(cp.Uri, participantUri)) { try { _conversation.ConferenceSession.LobbyManager.BeginAdmitLobbyParticipants(new List <ConversationParticipant>() { cp }, ar => { LobbyManager lobbyMgr = ar.AsyncState as LobbyManager; try { lobbyMgr.EndAdmitLobbyParticipants(ar); } catch (RealTimeException rtex) { _logger.Log("AcdConferenceServices failed to end admit a participant in the lobby", rtex); } }, _conversation.ConferenceSession.LobbyManager); } catch (InvalidOperationException ivoex) { _logger.Log("AcdConferenceServicesAnchor failed to begin admit a participant in the lobby", ivoex); } } }); return(true); } return(false); }
private void InitializeAgentTracking() { //Populate a list of agents assigned to Supervisor _matchMaker.Configuration.Agents.ForEach(agent => { if (SipUriCompare.Equals(agent.SupervisorUri, this._supervisor.SignInAddress)) { _listOfTrackedAgents.Add(agent); } }); //send the initial activity status to the Supervisor this.SendFullAgentActivityStatus(); //Fire a timer to send the agent activity deltas _tmrItem = new TimerItem(_wheel, new TimeSpan(0, 0, 0, AgentActivityRefreshPollingValue)); _tmrItem.Expired += RefreshAgentActivity; _tmrItem.Start(); }
private void ProcessPendingParticipants(Object sender, LobbyParticipantAttendanceChangedEventArgs args) { List <ConversationParticipant> listOfLobbyParticipants = new List <ConversationParticipant>(args.Added); listOfLobbyParticipants.ForEach(cp => { lock (_syncRoot) { _listOfAuthorizedParticipants.ForEach(ap => { if (SipUriCompare.Equals(ap, cp.Uri)) { try { _conversation.ConferenceSession.LobbyManager.BeginAdmitLobbyParticipants(new List <ConversationParticipant>() { cp }, ar => { LobbyManager lobbyMgr = ar.AsyncState as LobbyManager; try { lobbyMgr.EndAdmitLobbyParticipants(ar); } catch (RealTimeException rtex) { this._logger.Log("AdmitLobbyParticipant failed", rtex); } }, _conversation.ConferenceSession.LobbyManager); } catch (InvalidOperationException ivo) { this._logger.Log("AdmitLobbyParticipant failed", ivo); } } }); } }); }
internal bool ElevateToPresenter(string participantUri) { SipUriParser parser; if (SipUriParser.TryParse(participantUri, out parser)) { lock (_syncRoot) { _listOfPresenters.Add(participantUri); } List <ConversationParticipant> listOfParticipants = new List <ConversationParticipant>(_conversation.RemoteParticipants); listOfParticipants.ForEach(cp => { if (SipUriCompare.Equals(cp.Uri, participantUri)) { if (cp.Role != ConferencingRole.Leader) { _conversation.ConferenceSession.BeginModifyRole(cp, ConferencingRole.Leader, mr => { try { _conversation.ConferenceSession.EndModifyRole(mr); } catch (RealTimeException rtex) { this._logger.Log("ModifyRole failed", rtex); } }, null); } } }); return(true); } return(false); }
private void ProcessAllowedParticipants(Object sender, ParticipantAttendanceChangedEventArgs args) { List <ConversationParticipant> listOfParticipants = new List <ConversationParticipant>(args.Added); listOfParticipants.ForEach(cp => { lock (_syncRoot) { _listOfPresenters.ForEach(p => { if (SipUriCompare.Equals(p, cp.Uri)) { if (cp.Role != ConferencingRole.Leader) { try { _conversation.ConferenceSession.BeginModifyRole(cp, ConferencingRole.Leader, mr => { try { _conversation.ConferenceSession.EndModifyRole(mr); } catch (RealTimeException rtex) { this._logger.Log("ModifyRole failed", rtex); } }, null); } catch (InvalidOperationException ivoex) { _logger.Log("ModifyRole failed", ivoex); } } } }); } }); }
private void ProcessSupervisorControlChannelRequestReceived(object sender, ContextChannelRequestReceivedEventArgs args) { _logger.Log("RECEIVED REQUEST: AcdSupervisorSession received the following request: " + args.RequestType); switch (args.RequestType) { case ContextChannelRequestType.StartMonitoring: MonitoringRequest startMonitoringRequest = args.Request as MonitoringRequest; Agent agentToMonitor = null; foreach (Agent agent in _matchMaker.Configuration.Agents) { if (SipUriCompare.Equals(agent.SignInAddress, startMonitoringRequest.MonitoringChannel.Uri.ToString())) { agentToMonitor = agent; break; } } if (null == agentToMonitor) { _logger.Log("AcdSupervisorSession could not find the agent to monitor."); args.Request.SendResponse("failure"); return; } if (agentToMonitor.IsAllocated == false) { _logger.Log(String.Format("AcdSupervisorSession detected that the agent to monitor was deallocated {0}", agentToMonitor.SignInAddress)); args.Request.SendResponse("failure"); return; } if (_state == SupervisorSessionState.AgentMonitoring) { _monitoringSession.BeginShutDown(sd => { _monitoringSession.EndShutDown(sd); _monitoringSession = null; args.Request.SendResponse("Success"); this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking); try { this.BeginStartMonitoringSession(startMonitoringRequest.MonitoringChannel, agentToMonitor, sms => { try { this.EndStartMonitoringSession(sms); args.Request.SendResponse("success"); this.UpdateState(SupervisorSessionState.AgentMonitoring); return; } catch (RealTimeException rtex) { _logger.Log("AcdSupervisorSession fails to end start the monitoring session", rtex); args.Request.SendResponse("failure"); this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking); return; } }, null); } catch (InvalidOperationException ivoex) { _logger.Log("AcdSupervisorSession fails to begin start the monitoring session", ivoex); args.Request.SendResponse("failure"); this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking); return; } }, null); return; } try { this.BeginStartMonitoringSession(startMonitoringRequest.MonitoringChannel, agentToMonitor, sms => { try { this.EndStartMonitoringSession(sms); args.Request.SendResponse("success"); lock (_syncRoot) { if (_state == SupervisorSessionState.JoiningCustomerSession) { this.UpdateState(SupervisorSessionState.AgentMonitoring); } } } catch (RealTimeException rtex) { _logger.Log("AcdSupervisorSession fails to end start the monitoring session", rtex); args.Request.SendResponse("failure"); this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking); } }, null); } catch (InvalidOperationException ivoex) { _logger.Log("AcdSupervisorSession fails to begin start the monitoring session", ivoex); args.Request.SendResponse("failure"); this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking); } break; case ContextChannelRequestType.StopMonitoring: if (_state != SupervisorSessionState.AgentMonitoring) { _logger.Log("AcdSupervisorSession fails to stop monitoring the session as the supervisorsession is in an invalid state"); args.Request.SendResponse("Failure"); } else { _monitoringSession.BeginShutDown(sd => { _monitoringSession.EndShutDown(sd); _monitoringSession = null; args.Request.SendResponse("Success"); this.UpdateState(SupervisorSessionState.GeneralAgentActivityTracking); }, null); } break; default: _logger.Log("AcdSupervisorSession received a non-supported command"); args.Request.SendResponse("Failure"); break; } }
/// <summary> /// Parses the configuration file /// </summary> /// <param name="configXMLDoc"></param> /// <returns>true if the configuration file could be parsed successfully, false otherwise</returns> internal bool ProcessConfigurationFile(string configXMLDoc) { try { //Parse the config xml doc into an Xdocument XDocument configDoc = XDocument.Parse(configXMLDoc); //Use Linq to XML to get the platform _configuration = (from platform in configDoc.Descendants("platform") select new AcdPlatformConfiguration { ApplicationUserAgent = platform.Element("applicationUserAgent").Value, ApplicationUrn = platform.Element("applicationUrn").Value, PortalConfigurations = (from portal in platform.Element("portals").Descendants("portal") select new AcdPortalConfiguration { Uri = portal.Element("uri").Value, Token = portal.Element("token").Value, VoiceXmlEnabled = (portal.Element("voiceXmlEnabled") != null && portal.Element("voiceXmlEnabled").Value.Equals("true")) ? true : false, VoiceXmlPath = portal.Element("voiceXmlPath") != null ? portal.Element("voiceXmlPath").Value : null, WelcomeMessage = portal.Element("welcomeMessage").Value, ContextualWelcomeMessage = portal.Element("contextualWelcomeMessage").Value, ImBridgingMessage = portal.Element("imBridgingMessage").Value, ImPleaseHoldMessage = portal.Element("imPleaseHoldMessage").Value, FinalMessage = portal.Element("finalMessage").Value, TimeOutNoAgentAvailableMessage = portal.Element("timeOutNoAgentAvailableMessage").Value, Skills = (from skill in portal.Element("portalSkills").Descendants("portalSkill").Attributes() select(string) skill.Value).ToList <string>() }).ToList() }).First(); //Retrieve the matchmaker configuration _matchMakerConfiguration = (from matchMaker in configDoc.Element("platform").Descendants("matchMaker") select new AcdAgentMatchMakerConfiguration { MaxWaitTimeOut = int.Parse(matchMaker.Element("maxWaitTimeOut").Value), Uri = matchMaker.Element("uri").Value, AgentDashboardGuid = new Guid(matchMaker.Element("agentDashboardGuid").Value), SupervisorDashboardGuid = new Guid(matchMaker.Element("supervisorDashboardGuid").Value), FinalMessageToAgent = matchMaker.Element("agentPrompts").Element("finalMessageToAgent").Value, OfferToAgentMainPrompt = matchMaker.Element("agentPrompts").Element("mainPrompt").Value, OfferToAgentNoRecoPrompt = matchMaker.Element("agentPrompts").Element("noRecoPrompt").Value, OfferToAgentSilencePrompt = matchMaker.Element("agentPrompts").Element("silencePrompt").Value, MusicOnHoldFilePath = matchMaker.Element("musicOnHoldFilePath").Value, AgentMatchMakingPrompt = matchMaker.Element("agentMatchMakingPrompt").Value, FinalMessageToSupervisor = matchMaker.Element("supervisorPrompts").Element("finalMessageToSupervisor").Value, SupervisorWelcomePrompt = matchMaker.Element("supervisorPrompts").Element("welcomePrompt").Value, Skills = (from skill in matchMaker.Element("skills").Descendants("skill") select new Skill() { Name = skill.Attribute("name").Value, MainPrompt = skill.Element("mainPrompt").Value, NoRecoPrompt = skill.Element("noRecoPrompt").Value, SilencePrompt = skill.Element("silencePrompt").Value, RecognizedSkillPrompt = skill.Element("skillRecognizedMainPrompt").Value, Values = (from skillValue in skill.Descendants("skillValues").Elements() select skillValue.Value).ToList() }).ToList(), }).First(); //add the supervisors. _matchMakerConfiguration.Supervisors = (from supervisor in configDoc.Descendants("supervisors").Elements("supervisor") select new Supervisor() { SignInAddress = supervisor.Element("signInAddress").Value, PublicName = supervisor.Element("publicName").Value, InstantMessageColor = supervisor.Element("instantMessageColor").Value, }).ToList(); //Add the agents. This must be done separately from the previous line since we need the skills //from the matchMakerConfiguration object. _matchMakerConfiguration.Agents = (from agent in configDoc.Descendants("agents").Elements("agent") select new Agent(_logger) { PublicName = agent.Element("publicName").Value, SignInAddress = agent.Element("signInAddress").Value, SupervisorUri = agent.Element("supervisorUri").Value, InstantMessageColor = agent.Element("instantMessageColor").Value, Skills = (from agentSkill in agent.Descendants("agentSkills").Elements() select new AgentSkill(Skill.FindSkill(agentSkill.Attribute("name").Value, _matchMakerConfiguration.Skills), agentSkill.Value)).ToList(), }).ToList(); //Assign agent to supervisor and vice versa _matchMakerConfiguration.Agents.ForEach(agent => { _matchMakerConfiguration.Supervisors.ForEach(sup => { if (SipUriCompare.Equals(sup.SignInAddress, agent.SupervisorUri)) { agent.Supervisor = sup; sup.Agents.Add(agent); } }); }); return(true); } catch (Exception ex) { _logger.Log("AcdPlatform failed parsing the configuration file", ex); return(false); } }