Beispiel #1
0
        /// <summary>
        /// Starts the push notification task.
        /// </summary>
        public void InitHttpNotificationTask()
        {
            // Obtain a reference to the existing task, if any.
            VoipHttpIncomingCallTask incomingCallTask = ScheduledActionService.Find(incomingCallTaskName) as VoipHttpIncomingCallTask;

            if (incomingCallTask != null)
            {
                if (incomingCallTask.IsScheduled == false)
                {
                    // The incoming call task has been unscheduled due to OOM or throwing an unhandled exception twice in a row
                    ScheduledActionService.Remove(incomingCallTaskName);
                }
                else
                {
                    // The incoming call task has been scheduled and is still scheduled so there is nothing more to do
                    return;
                }
            }

            try
            {
                incomingCallTask             = new VoipHttpIncomingCallTask(incomingCallTaskName, pushChannelName);
                incomingCallTask.Description = "Linphone incoming call task";
                ScheduledActionService.Add(incomingCallTask);
            }
            catch (Exception)
            {
            }
        }
        protected override void OnInvoke(ScheduledTask task)
        {
            Debug.WriteLine("[Mediastreamer2ScheduledAgent] ScheduledAgentImpl has been invoked with argument of type {0}.", task.GetType());
            VoipHttpIncomingCallTask incomingCallTask = task as VoipHttpIncomingCallTask;

            if (incomingCallTask != null)
            {
                this.isIncomingCallAgent = true;
                Debug.WriteLine("[IncomingCallAgent] Received VoIP Incoming Call task");
            }
            else
            {
                VoipKeepAliveTask keepAliveTask = task as VoipKeepAliveTask;
                if (keepAliveTask != null)
                {
                    this.isIncomingCallAgent = false;
                    Debug.WriteLine("[KeepAliveAgent] Keep Alive task");
                    base.NotifyComplete();
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Unknown scheduled task type {0}", task.GetType()));
                }
            }
        }
        /// <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()));
                }
            }
        }
        protected override void OnInvoke(ScheduledTask task)
        {
            Debug.WriteLine("[LinphoneScheduledAgent] ScheduledAgentImpl has been invoked with argument of type {0}.", task.GetType());
            AgentHost.OnAgentStarted();
            VoipHttpIncomingCallTask incomingCallTask = task as VoipHttpIncomingCallTask;

            if (incomingCallTask != null)
            {
                this.isIncomingCallAgent = true;
                Debug.WriteLine("[IncomingCallAgent] Received VoIP Incoming Call task");

                BackgroundManager.Instance.OopServer.CallController.IncomingCallViewDismissed = OnIncomingCallDialogDismissed;
                BackgroundManager.Instance.InitLinphoneCore();
            }
            else
            {
                VoipKeepAliveTask keepAliveTask = task as VoipKeepAliveTask;
                if (keepAliveTask != null)
                {
                    this.isIncomingCallAgent = false;
                    Debug.WriteLine("[KeepAliveAgent] Keep Alive task");

                    if (DeviceNetworkInformation.IsNetworkAvailable)
                    {
                        var server = BackgroundManager.Instance.OopServer;
                        InitManager.CreateLinphoneCore(server, this, OutputTraceLevel.Message);
                        server.LinphoneCore.NetworkReachable = true;
                        server.LinphoneCore.IterateEnabled   = true;
                        Debug.WriteLine("[KeepAliveAgent] Linphone Core created");
                    }
                    else
                    {
                        Debug.WriteLine("[KeepAliveAgent] Not connected, can't refresh register");
                        base.NotifyComplete();
                    }
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Unknown scheduled task type {0}", task.GetType()));
                }
            }
        }
        private void InitHttpNotificationTask()
        {
            // Obtain a reference to the existing task, if any.
            var incomingCallTask = ScheduledActionService.Find(IncomingCallTaskName) as VoipHttpIncomingCallTask;
            if (incomingCallTask != null)
            {
                if (incomingCallTask.IsScheduled == false)
                {
                    // The incoming call task has been unscheduled due to OOM or throwing an unhandled exception twice in a row
                    ScheduledActionService.Remove(IncomingCallTaskName);
                }
                else
                {
                    // The incoming call task has been scheduled and is still scheduled so there is nothing more to do
                    return;
                }
            }

            // Create a new incoming call task.
            incomingCallTask = new VoipHttpIncomingCallTask(IncomingCallTaskName, AppPushChannel);
            incomingCallTask.Description = "Incoming call task";
            ScheduledActionService.Add(incomingCallTask);
        }
Beispiel #6
0
        private void InitHttpNotificationTask()
        {
            // Obtain a reference to the existing task, if any.
            var incomingCallTask = ScheduledActionService.Find(IncomingCallTaskName) as VoipHttpIncomingCallTask;

            if (incomingCallTask != null)
            {
                if (incomingCallTask.IsScheduled == false)
                {
                    // The incoming call task has been unscheduled due to OOM or throwing an unhandled exception twice in a row
                    ScheduledActionService.Remove(IncomingCallTaskName);
                }
                else
                {
                    // The incoming call task has been scheduled and is still scheduled so there is nothing more to do
                    return;
                }
            }

            // Create a new incoming call task.
            incomingCallTask             = new VoipHttpIncomingCallTask(IncomingCallTaskName, AppPushChannel);
            incomingCallTask.Description = "Incoming call task";
            ScheduledActionService.Add(incomingCallTask);
        }
Beispiel #7
0
        public static void InitHttpNotificationTask()
        {
            try
            {
                // Obtain a reference to the existing task, if any.
                var incomingCallTask = ScheduledActionService.Find(incomingCallTaskName) as VoipHttpIncomingCallTask;
                if (incomingCallTask != null)
                {
                    if (incomingCallTask.IsScheduled == false)
                    {
                        // The incoming call task has been unscheduled due to OOM or throwing an unhandled exception twice in a row
                        ScheduledActionService.Remove(incomingCallTaskName);
                    }
                    else
                    {
                        // The incoming call task has been scheduled and is still scheduled so there is nothing more to do
                        return;
                    }
                }

                // Create a new incoming call task.
                incomingCallTask             = new VoipHttpIncomingCallTask(incomingCallTaskName, Constants.ToastNotificationChannelName);
                incomingCallTask.Description = "Incoming call task";

                foreach (var action in ScheduledActionService.GetActions <ScheduledAction>())
                {
                    ScheduledActionService.Remove(action.Name);
                }

                ScheduledActionService.Add(incomingCallTask);
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write("InitHttpNotificationTask ScheduledActionService.Add exception\n" + ex);
            }
        }
        /// <summary>
        /// Starts the push notification task.
        /// </summary>
        public void InitHttpNotificationTask()
        {
            // Obtain a reference to the existing task, if any. 
            VoipHttpIncomingCallTask incomingCallTask = ScheduledActionService.Find(incomingCallTaskName) as VoipHttpIncomingCallTask;
            if (incomingCallTask != null)
            {
                if (incomingCallTask.IsScheduled == false)
                {
                    // The incoming call task has been unscheduled due to OOM or throwing an unhandled exception twice in a row 
                    ScheduledActionService.Remove(incomingCallTaskName);
                }
                else
                {
                    // The incoming call task has been scheduled and is still scheduled so there is nothing more to do 
                    return;
                }
            }

            try
            {
                incomingCallTask = new VoipHttpIncomingCallTask(incomingCallTaskName, pushChannelName);
                incomingCallTask.Description = "Linphone incoming call task";
                ScheduledActionService.Add(incomingCallTask);
            }
            catch (Exception)
            {

            }
        }