Пример #1
0
        /// <summary>
        /// The first call has become active.
        /// </summary>
        protected override void OnFirstCallStarting()
        {
            Debug.WriteLine("[CallInProgressAgentImpl] The first call has started.");

            // Indicate that an agent has started running
            AgentHost.OnAgentStarted();
        }
Пример #2
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        protected override void OnInvoke(ScheduledTask task)
        {
            Debug.WriteLine("[ScheduledAgentImpl] ScheduledAgentImpl has been invoked with argument of type {0}.", task.GetType());

            // Indicate that an agent has started running
            AgentHost.OnAgentStarted();

            VoipHttpIncomingCallTask incomingCallTask = task as VoipHttpIncomingCallTask;

            if (incomingCallTask != null)
            {
                this.isIncomingCallAgent = true;

                // Parse the the incoming push notification payload
                Notification pushNotification;
                using (MemoryStream ms = new MemoryStream(incomingCallTask.MessageBody))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(Notification));
                    pushNotification = (Notification)xs.Deserialize(ms);
                }

                Debug.WriteLine("[{0}] Incoming call from caller {1}, number {2}", ScheduledAgentImpl.incomingCallAgentId, pushNotification.Name, pushNotification.Number);

                // Initiate incoming call processing
                // If you want to pass in additional information such as pushNotification.Number, you can
#if FIXME_TO_BE_IMPLEMENTED
                bool incomingCallProcessingStarted = BackEnd.Globals.Instance.CallController.OnIncomingCallReceived(pushNotification.Name, pushNotification.Number, this.OnIncomingCallDialogDismissed);

                if (!incomingCallProcessingStarted)
                {
                    // For some reasons, the incoming call processing was not started.
                    // There is nothing more to do.
                    this.Complete();
                    return;
                }
#endif
            }
            else
            {
                VoipKeepAliveTask keepAliveTask = task as VoipKeepAliveTask;
                if (keepAliveTask != null)
                {
                    this.isIncomingCallAgent = false;

                    // Refresh tokens, get new certs from server, etc.
                    BackEnd.Globals.Instance.DoPeriodicKeepAlive();
                    this.Complete();
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Unknown scheduled task type {0}", task.GetType()));
                }
            }
        }
        /// <summary>
        /// A method that is called as a result of
        /// </summary>
        protected override void OnLaunched()
        {
            Debug.WriteLine("[ForegroundLifetimeAgentImpl] The UI has entered the foreground.");

            // Debug.WriteLine("[ForegroundLifetimeAgentImpl] Start SIP service.");
            // Globals.Instance.SipService.Start();
            // Globals.Instance.SipService.Register();

            // Indicate that an agent has started running
            AgentHost.OnAgentStarted();
        }