public void Run(IBackgroundTaskInstance taskInstance)
        {
            var defferal = taskInstance.GetDeferral();

            var taskHelper = new TaskHelper();

            var signalingTask = taskHelper.GetTask(nameof(SignalingTask));

            var connOwner = new ConnectionOwner
            {
                OwnerId = signalingTask.TaskId.ToString()
            };

            Hub.Instance.SignalingSocketService.ConnectToSignalingServer(connOwner);

            Hub.Instance.SignalingClient.Register(new Registration
            {
                Name = RegistrationSettings.Name,
                UserId = RegistrationSettings.UserId,
                Domain = RegistrationSettings.Domain,
                PushNotificationChannelURI = RegistrationSettings.PushNotificationChannelURI
            });

            defferal.Complete();
        }
Example #2
0
        private static async System.Threading.Tasks.Task<IBackgroundTaskRegistration> RegisterSignalingTask(TaskHelper helper, bool registerAgain = true)
        {
            var signalingTask = helper.GetTask(nameof(SignalingTask)) ??
                    await helper.RegisterTask(nameof(SignalingTask), typeof(SignalingTask).FullName,
                            new SocketActivityTrigger(), registerAgain).AsTask();

            return signalingTask;

        }
Example #3
0
        void UnRegisterAllBackgroundTask()
        {
          var helper = new TaskHelper();
          var signalingReg = helper.GetTask(nameof(SignalingTask));
          if (signalingReg != null)
              signalingReg.Unregister(true);

          var regOp = helper.GetTask(nameof(PushNotificationTask));
          if (regOp != null)
              regOp.Unregister(true);
        }
Example #4
0
        private static async System.Threading.Tasks.Task RegisterForPush(TaskHelper helper, bool registerAgain = true)
        {
            try
            {
                PushNotificationHelper.RegisterPushNotificationChannel();

                var pushNotificationTask = await helper.RegisterTask(nameof(PushNotificationTask), typeof(PushNotificationTask).FullName, 
                  new PushNotificationTrigger(), registerAgain).AsTask();
                if (pushNotificationTask == null)
                {
                    Debug.WriteLine("Push notification background task is not started");
                }

            }
            catch (Exception e)
            {
                Debug.WriteLine($"Failed to register for push notification. Error: {e.Message}");
            }
        }
Example #5
0
        private static async System.Threading.Tasks.Task RegisterForPush(bool registerAgain = true)
        {
            PushNotificationHelper.RegisterPushNotificationChannel();

            var helper = new TaskHelper();
            var pushNotificationTask = await helper.RegisterTask(nameof(PushNotificationTask),
                                                                 typeof(PushNotificationTask).FullName,
                                                                 new PushNotificationTrigger(),
                                                                 registerAgain);                                                                 
            if (pushNotificationTask == null)
            {
                Debug.WriteLine("Push notification background task is not started");
            }
        }
Example #6
0
 private static async Task<IBackgroundTaskRegistration> RegisterSessionConnectedTask(TaskHelper helper)
 {
     var sessionConnTask = helper.GetTask(nameof(SessionConnectedTask)) ??
         await helper.RegisterTask(nameof(SessionConnectedTask),
                                   typeof(SessionConnectedTask).FullName,
                                   new SystemTrigger(SystemTriggerType.InternetAvailable, oneShot: false),
                                   removeIfRegistered: false);
     return sessionConnTask;
 }