Exemple #1
0
        public ApplePushService(IPushChannelFactory pushChannelFactory, ApplePushChannelSettings channelSettings, IPushServiceSettings serviceSettings)
            : base(pushChannelFactory ?? new ApplePushChannelFactory(), channelSettings, serviceSettings)
        {
            var appleChannelSettings = channelSettings;

            cancelTokenSource = new CancellationTokenSource();

            //allow control over feedback call interval, if set to zero, don't make feedback calls automatically
            if (appleChannelSettings.FeedbackIntervalMinutes > 0)
            {
                feedbackService = new FeedbackService();
                feedbackService.OnFeedbackReceived  += feedbackService_OnFeedbackReceived;
                feedbackService.OnFeedbackException += (Exception ex) => this.RaiseServiceException(ex);

                if (timerFeedback == null)
                {
                    timerFeedback = new Timer(new TimerCallback((state) =>
                    {
                        try { feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token); }
                        catch (Exception ex) { base.RaiseServiceException(ex); }

                        //Timer will run first after 10 seconds, then every 10 minutes to get feedback!
                    }), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes));
                }
            }

            //Apple has documented that they only want us to use 20 connections to them
            base.ServiceSettings.MaxAutoScaleChannels = 20;
        }
Exemple #2
0
		public ApplePushService(IPushChannelFactory pushChannelFactory, ApplePushChannelSettings channelSettings, IPushServiceSettings serviceSettings)
			: base(pushChannelFactory ?? new ApplePushChannelFactory(), channelSettings, serviceSettings)
		{
			var appleChannelSettings = channelSettings;
			cancelTokenSource = new CancellationTokenSource();

			//allow control over feedback call interval, if set to zero, don't make feedback calls automatically
			if (appleChannelSettings.FeedbackIntervalMinutes > 0)
			{
				feedbackService = new FeedbackService();
				feedbackService.OnFeedbackReceived += feedbackService_OnFeedbackReceived;
				feedbackService.OnFeedbackException += (Exception ex) => this.RaiseServiceException (ex);

				if (timerFeedback == null)
				{
					timerFeedback = new Timer(new TimerCallback((state) =>
					{
						try { feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token); }
						catch (Exception ex) { base.RaiseServiceException(ex); }

						//Timer will run first after 10 seconds, then every 10 minutes to get feedback!
					}), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes));
				}
			}

			//Apple has documented that they only want us to use 20 connections to them
			base.ServiceSettings.MaxAutoScaleChannels = 20;
		}
        public ApplePushService(PushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            cancelTokenSource = new CancellationTokenSource();
            feedbackService = new FeedbackService();
            feedbackService.OnFeedbackReceived += new FeedbackService.FeedbackReceivedDelegate(feedbackService_OnFeedbackReceived);
            timerFeedback = new Timer(new TimerCallback((state) =>
            {
                feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token);

                //Timer will run first after 10 seconds, then every 10 minutes to get feedback!
            }),null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(10));
        }
Exemple #4
0
        private static void ReceiveFeedback()
        {
            FeedbackService fs = new FeedbackService();
            fs.OnFeedbackReceived += Fs_OnFeedbackReceived;

            //			var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Resources/PushSharp.Apns.Sandbox.p12"));
            //			ApplePushChannelSettings appleSettings = new ApplePushChannelSettings (false, appleCert, "Lize4Rune");

            var appleCert = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../Resources/OLBPhoneSandboxCertificate.p12"));
            ApplePushChannelSettings appleSettings = new ApplePushChannelSettings(false, appleCert, "0lbSandb0x");

            fs.Run(appleSettings);
        }
        public ApplePushService(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings)
            : base(channelSettings, serviceSettings)
        {
            var appleChannelSettings = channelSettings as ApplePushChannelSettings;

            //cancelTokenSource = new CancellationTokenSource();
            feedbackService = new FeedbackService();
            feedbackService.OnFeedbackReceived += new FeedbackService.FeedbackReceivedDelegate(feedbackService_OnFeedbackReceived);

            //allow control over feedback call interval, if set to zero, don't make feedback calls automatically
            if (appleChannelSettings.FeedbackIntervalMinutes > 0)
            {
                timerFeedback = new Timer(new TimerCallback((state) =>
                {
                    try { feedbackService.Run(channelSettings as ApplePushChannelSettings /*, this.cancelTokenSource.Token*/); }
                    catch (Exception ex) { this.Events.RaiseChannelException(ex); }

                    //Timer will run first after 10 seconds, then every 10 minutes to get feedback!
                }), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes));
            }
        }
        public ApplePushService(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            var appleChannelSettings = channelSettings as ApplePushChannelSettings;
            cancelTokenSource = new CancellationTokenSource();
            feedbackService = new FeedbackService();
            feedbackService.OnFeedbackReceived += new FeedbackService.FeedbackReceivedDelegate(feedbackService_OnFeedbackReceived);

            //allow control over feedback call interval, if set to zero, don't make feedback calls automatically
            if (appleChannelSettings.FeedbackIntervalMinutes > 0)
            {
                timerFeedback = new Timer(new TimerCallback((state) =>
                {
                    try { feedbackService.Run(channelSettings as ApplePushChannelSettings, this.cancelTokenSource.Token); }
                    catch (Exception ex) { this.Events.RaiseChannelException(ex); }

                    //Timer will run first after 10 seconds, then every 10 minutes to get feedback!
                }), null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(appleChannelSettings.FeedbackIntervalMinutes));

            }
        }