public void RequestUnmuteCallViaSIPEndpoint(IInteractionVoice ixnVoice)
 {
     // To go to the main thread
     if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess())
     {
         object result = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send,
                                                               new RequestUnmuteCallViaSIPEndpointDelegate(RequestUnmuteCallViaSIPEndpoint), ixnVoice);
     }
     else
     {
         log.Info("Execute RequestUnmuteCallViaSIPEndpoint");
         if (JabraOptions.Default.IsUsingGenesysSIPEndpoint())
         {
             try
             {
                 if (ixnVoice != null)
                 {
                     SIPEndpoint sipEndpoint = container.Resolve <ISIPEndpointCommunication>().FindSIPEndpoint(ixnVoice);
                     if (sipEndpoint != null)
                     {
                         sipEndpoint.IsMicrophoneMuted = false;
                     }
                 }
             }
             catch (Exception exp)
             {
                 log.Error("Exception in RequestMuteCallViaSIPEndpoint", exp);
             }
         }
     }
 }
        private void UnregisterSIPEPEventHandlers(IInteractionVoice interactionVoice)
        {
            if (JabraOptions.Default.IsUsingGenesysSIPEndpoint())
            {
                try
                {
                    SIPEndpoint sipEndpoint = container.Resolve <ISIPEndpointCommunication>().FindSIPEndpoint(interactionVoice);

                    if (sipEndpoint != null)
                    {
                        // this.sipEP.EndpointStatusChanged += new System.EventHandler<EventArgs<bool>>(SIPEP_StatusChanged);
                        if (startedSipEndpoints.ContainsKey(sipEndpoint))
                        {
                            sipEndpoint.PropertyChanged       -= new PropertyChangedEventHandler(SIPEP_PropertyChanged);
                            sipEndpoint.EndpointStatusChanged -= new System.EventHandler <EventArgs <bool> >(SIPEP_StatusChanged);

                            startedSipEndpoints.Remove(sipEndpoint);
                        }
                    }
                }
                catch (Exception exp)
                {
                    log.Error("Exception in UnregisterSIPEPEventHandlers", exp);
                }
            }
        }
        private void TriggerVoiceChainOfCommands(IInteractionVoice ixnVoice, String commandName)
        {
            try
            {
                IDictionary <string, object> parameters = new Dictionary <string, object>();

                parameters.Add("CommandParameter", ixnVoice);
                // parameters.Add("OtherKey", "OtherValue");

                IChainOfCommand voiceCallCommand = commandManager.GetChainOfCommandByName(commandName);

                if (voiceCallCommand != null)
                {
                    voiceCallCommand.Execute(parameters);

                    // Async way

                    /*
                     * voiceCallCommand.BeginExecute(parameters,
                     *      delegate(IAsyncResult ar)
                     *      {
                     *          voiceCallCommand.EndExecute(ar);
                     *      }, null);
                     */
                }
            }
            catch (Exception exp)
            {
                log.Error("Exception in TriggerVoiceChainOfCommands", exp);
            }
        }
        public void RequestUnmuteCallViaSIPEndpoint(string token)
        {
            IInteractionVoice interactionVoice = this.FindVoiceInteraction(token);

            if (interactionVoice != null)
            {
                RequestUnmuteCallViaSIPEndpoint(interactionVoice);
            }
        }
 public void RequestRetrieveCall(IInteractionVoice ixnVoice)
 {
     // To go to the main thread
     if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess())
     {
         object result = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send,
                                                               new RequestRetrieveCallDelegate(RequestRetrieveCall), ixnVoice);
     }
     else
     {
         log.Info("Execute RequestRetrieveCall");
         TriggerVoiceChainOfCommands(ixnVoice, "InteractionVoiceRetrieveCall");
     }
 }
        public IInteractionVoice FindVoiceInteraction(string token)
        {
            IInteractionVoice interactionVoice = null;

            foreach (var interaction in interactionManager.Interactions)
            {
                IInteractionVoice iv = interaction as IInteractionVoice;
                if (iv != null && iv.Media.IsSIPMedia)
                {
                    // TODO
                    // Decide how to leverage token to recognize interaction (as there can be multiple active calls)
                    // token can leverage Interaction.Id, ConnectionId, ANI, ..., or a key/value pair in UserData
                    interactionVoice = iv;
                    break;
                }
            }
            return(interactionVoice);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="progress">The progress.</param>
        /// <returns></returns>
        public bool Execute(IDictionary <string, object> parameters, IProgressUpdater progress)
        {
            // To go to the main thread
            if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess())
            {
                object result = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, new ExecuteDelegate(Execute), parameters, progress);
                return((bool)result);
            }
            else
            {
                // Ok, we are in the main thread

                log.Info("Execute");

                // Get the parameter
                IInteractionVoice interactionVoice = parameters["CommandParameter"] as IInteractionVoice;

                // Prompt the alert dialog
                return(MessageBox.Show("Do you really want to release this call?\r\nThe call",
                                       "Release the call?", MessageBoxButton.YesNo) == MessageBoxResult.No);
            }
        }
        private void InteractionEvent(object sender, EventArgs <IInteraction> e)
        {
            IInteraction      interaction = e.Value;
            IInteractionVoice iv          = interaction as IInteractionVoice;

            if (iv != null && iv.Media.IsSIPMedia)
            {
                IMessage receivedEvent = iv.EntrepriseLastInteractionEvent;

                if (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.PresentedIn)
                {
                    if (receivedEvent.Id == EventRinging.MessageId)
                    {
                        RegisterSIPEPEventHandlers(iv);

                        /* Ringing */
                        log.Info("InteractionEvent: Ringing");

                        // Update Jabra device state
                        SetRinger(true, iv.PhoneNumber);
                        incomingCall = iv;
                    }
                }
                else if (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Connected)
                {
                    if (receivedEvent.Id == EventEstablished.MessageId)
                    {
                        /* Established */
                        log.Info("InteractionEvent: Established");

                        // Update Jabra device state
                        SetRinger(false);
                        SetHookState(true);
                        incomingCall = null;
                        activeCall   = iv;

                        // Always start unmuted
                        isCallMuted = false;
                        SetMicrophoneMuted(false);
                    }
                    else if (receivedEvent.Id == EventRetrieved.MessageId)
                    {
                        /* Retrieved */
                        log.Info("InteractionEvent: Retrieved");

                        // Update Jabra device state
                        SetHookState(true);

                        heldCalls.Remove(iv);
                        if (heldCalls.Count == 0)
                        {
                            SetCallOnHold(false);
                        }
                        activeCall = iv;

                        // Always start unmuted
                        isCallMuted = false;
                        SetMicrophoneMuted(false);
                    }
                }
                else if (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Held)
                {
                    if (receivedEvent.Id == EventHeld.MessageId)
                    {
                        /* Held */
                        log.Info("InteractionEvent: Held");

                        // Update Jabra device state
                        SetCallOnHold(true);
                        SetHookState(false);
                        activeCall = null;
                        heldCalls.Add(iv);
                    }
                }
                else if ((iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Ended) ||
                         (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Abandonned) ||
                         (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Dropped) ||
                         (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Redirected))
                {
                    // Sent two times....

                    /* Ended */
                    log.Info("InteractionEvent: Ended");

                    // Update Jabra device state
                    SetRinger(false);
                    if (iv == activeCall)
                    {
                        SetHookState(false);
                        activeCall = null;
                    }
                    else
                    {
                        if (heldCalls.Contains(iv))
                        {
                            heldCalls.Remove(iv);
                            if (heldCalls.Count == 0)
                            {
                                SetCallOnHold(false);
                            }
                        }
                    }
                }
                else if (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.PresentedOut)
                {
                    if (receivedEvent.Id == EventDialing.MessageId)
                    {
                        RegisterSIPEPEventHandlers(iv);

                        /* Dialing */
                        log.Info("InteractionEvent: Dialing");
                    }
                    else if (receivedEvent.Id == EventNetworkReached.MessageId)
                    {
                    }
                }
                else if (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.Busy)
                {
                }
                else if (iv.State == Genesyslab.Enterprise.Model.Interaction.InteractionStateType.InvalidDestination)
                {
                }
            }
        }