コード例 #1
0
        public PushServiceBase(TChannelSettings channelSettings, PushServiceSettings serviceSettings)
        {
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();
            this.ChannelSettings = channelSettings;

            this.queuedNotifications = new Queue <Notification>();

            /*timerCheckScale = new Timer(new TimerCallback((state) =>
             * {
             *      CheckScale();
             * }), null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));*/

            CheckScale();
            distributerThread = new Thread(new ThreadStart(Distributer));
            //distributerTask = new Task(Distributer, TaskCreationOptions.LongRunning);
            //distributerTask.ContinueWith((ft) =>
            //{
            //	var ex = ft.Exception;

            //		}, TaskContinuationOptions.OnlyOnFaulted);
            //	distributerTask.Start();

            distributerThread.Start();
            IsStopping = false;
        }
コード例 #2
0
        public ApplePushChannel(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            this.appleSettings = channelSettings;

            certificate = this.appleSettings.Certificate;

            certificates = new X509CertificateCollection();

            if (appleSettings.AddLocalAndMachineCertificateStores)
            {
                var store = new X509Store(StoreLocation.LocalMachine);
                certificates.AddRange(store.Certificates);

                store = new X509Store(StoreLocation.CurrentUser);
                certificates.AddRange(store.Certificates);
            }

            certificates.Add(certificate);

            if (this.appleSettings.AdditionalCertificates != null)
                foreach (var addlCert in this.appleSettings.AdditionalCertificates)
                    certificates.Add(addlCert);

            //Start our cleanup task
            taskCleanup = new Task(() => Cleanup(), TaskCreationOptions.LongRunning);
            taskCleanup.ContinueWith((t) => { var ex = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted);
            taskCleanup.Start();
        }
コード例 #3
0
        public ApplePushService(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(new ApplePushChannelFactory(channelSettings), serviceSettings)
        {
            var appleChannelSettings = channelSettings;
            cancelTokenSource = new CancellationTokenSource();
            feedbackService = new FeedbackService();
            feedbackService.OnFeedbackReceived +=
                this.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(
                    state =>
                        {
                            try
                            {
                                this.feedbackService.Run(
                                    channelSettings, this.cancelTokenSource.Token);
                            }
                            catch (Exception ex)
                            {
                                this.Events.RaiseChannelException(ex, PlatformType.Apple);
                            }

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

            }
        }
コード例 #4
0
        public AndroidPushChannel(AndroidPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            androidSettings = channelSettings;

            //Go get the auth token from google
            try
            {
                RefreshGoogleAuthToken();
            }
            catch (GoogleLoginAuthorizationException glaex)
            {
                this.Events.RaiseChannelException(glaex);
            }

            transport = new C2dmMessageTransportAsync();
            transport.UpdateGoogleClientAuthToken += new Action<string>((newToken) =>
            {
                this.googleAuthToken = newToken;
            });

            transport.MessageResponseReceived += new Action<C2dmMessageTransportResponse>(transport_MessageResponseReceived);

            transport.UnhandledException += new Action<AndroidNotification, Exception>(transport_UnhandledException);
        }
コード例 #5
0
ファイル: GcmPushChannel.cs プロジェクト: rture/PushSharp
        public GcmPushChannel(GcmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            gcmSettings = channelSettings;

            transport = new GcmMessageTransportAsync();

            transport.MessageResponseReceived += new Action<GcmMessageTransportResponse>(transport_MessageResponseReceived);

            transport.UnhandledException += new Action<GcmNotification, Exception>(transport_UnhandledException);
        }
コード例 #6
0
        public PushServiceBase(ChannelFactory channelFactory, PushServiceSettings serviceSettings = null)
        {
            this.channelFactory = channelFactory;
            this.Events = new ChannelEvents();
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();

            this.queuedNotifications = new ConcurrentQueue<Notification>();

            ChannelScaler.Start();

            this.BeginSending();
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        public PushChannelBase(PushChannelSettings channelSettings, PushServiceSettings serviceSettings)
        {
            this.stopping = false;
            //this.CancelTokenSource = new CancellationTokenSource();
            //this.CancelToken = CancelTokenSource.Token;

            this.queuedNotifications = new Queue <Notification>();

            this.ChannelSettings = channelSettings;
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();

            //Start our sending task
            taskSender = new Thread(new ThreadStart(Sender));
            taskSender.Start();
        }
コード例 #9
0
ファイル: ApplePushChannel.cs プロジェクト: phaufe/PushSharp
        public ApplePushChannel(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            this.appleSettings = channelSettings;

            certificate = this.appleSettings.Certificate;

            certificates = new X509CertificateCollection();
            certificates.Add(certificate);

            //Start our cleanup task
            taskCleanup = new Task(() => Cleanup(), TaskCreationOptions.LongRunning);
            taskCleanup.ContinueWith((t) => { var ex = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted);
            taskCleanup.Start();
        }
コード例 #10
0
        public PushChannelBase(PushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
        {
            this.stopping          = false;
            this.CancelTokenSource = new CancellationTokenSource();
            this.CancelToken       = CancelTokenSource.Token;

            this.queuedNotifications = new ConcurrentQueue <Notification>();

            this.ChannelSettings = channelSettings;
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();

            //Start our sending task
            taskSender = new Task(() => Sender(), TaskCreationOptions.LongRunning);
            taskSender.ContinueWith((t) => { var ex = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted);
            taskSender.Start();
        }
コード例 #11
0
ファイル: PushChannelBase.cs プロジェクト: rture/PushSharp
        public PushChannelBase(PushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
        {
            this.stopping = false;
            this.CancelTokenSource = new CancellationTokenSource();
            this.CancelToken = CancelTokenSource.Token;

            this.queuedNotifications = new ConcurrentQueue<Notification>();

            this.ChannelSettings = channelSettings;
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();

            //Start our sending task
            taskSender = new Task(() => Sender(), TaskCreationOptions.LongRunning);
            taskSender.ContinueWith((t) => { var ex = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted);
            taskSender.Start();
        }
コード例 #12
0
        public ApplePushChannel(ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
            : base(channelSettings, serviceSettings)
        {
            this.appleSettings = channelSettings;

            //Need to load the private key seperately from apple
            // Fixed by [email protected] :
            //      The default is UserKeySet, which has caused internal encryption errors,
            //      Because of lack of permissions on most hosting services.
            //      So MachineKeySet should be used instead.
            certificate = new X509Certificate2(this.appleSettings.CertificateData, this.appleSettings.CertificateFilePassword,
                X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);

            certificates = new X509CertificateCollection();
            certificates.Add(certificate);

            //Start our cleanup task
            taskCleanup = new Task(() => Cleanup(), TaskCreationOptions.LongRunning);
            taskCleanup.ContinueWith((t) => { var ex = t.Exception; }, TaskContinuationOptions.OnlyOnFaulted);
            taskCleanup.Start();
        }
コード例 #13
0
        public PushServiceBase(TChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
        {
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();
            this.ChannelSettings = channelSettings;

            this.queuedNotifications = new ConcurrentQueue <Notification>();

            timerCheckScale = new Timer(new TimerCallback((state) =>
            {
                CheckScale();
            }), null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));

            CheckScale();

            distributerTask = new Task(Distributer, TaskCreationOptions.LongRunning);
            distributerTask.ContinueWith((ft) =>
            {
                var ex = ft.Exception;
            }, TaskContinuationOptions.OnlyOnFaulted);
            distributerTask.Start();

            stopping = false;
        }
コード例 #14
0
ファイル: PushServiceBase.cs プロジェクト: rture/PushSharp
        public PushServiceBase(PushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
        {
            this.ServiceSettings = serviceSettings ?? new PushServiceSettings();
            this.ChannelSettings = channelSettings;

            this.queuedNotifications = new ConcurrentQueue<Notification>();

            timerCheckScale = new Timer(new TimerCallback((state) =>
            {
                CheckScale();
            }), null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));

            CheckScale();

            distributerTask = new Task(Distributer, TaskCreationOptions.LongRunning);
            distributerTask.ContinueWith((ft) =>
            {
                var ex = ft.Exception;

            }, TaskContinuationOptions.OnlyOnFaulted);
            distributerTask.Start();

            stopping = false;
        }
コード例 #15
0
ファイル: AndroidPushService.cs プロジェクト: rture/PushSharp
 public AndroidPushService(PushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
     : base(channelSettings, serviceSettings)
 {
 }
コード例 #16
0
 public WindowsPhonePushChannel(WindowsPhonePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
     : base(channelSettings, serviceSettings)
 {
     windowsPhoneSettings = channelSettings;
 }
コード例 #17
0
ファイル: GcmPushService.cs プロジェクト: bobbles31/PushSharp
 public GcmPushService(GcmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
     : base(new GcmPushChannelFactory(channelSettings), serviceSettings)
 {
 }
コード例 #18
0
ファイル: PushService.cs プロジェクト: nuttapol/PushSharp
 public void StartBlackberryPushService(Blackberry.BlackberryPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     bbService = new Blackberry.BlackberryPushService(channelSettings, serviceSettings);
     bbService.Events.RegisterProxyHandler(this.Events);
 }
コード例 #19
0
ファイル: PushService.cs プロジェクト: nuttapol/PushSharp
 public void StartApplePushService(Apple.ApplePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     appleService = new Apple.ApplePushService(channelSettings, serviceSettings);
     appleService.Events.RegisterProxyHandler(this.Events);
 }
コード例 #20
0
ファイル: PushService.cs プロジェクト: nuttapol/PushSharp
 public void StartAndroidPushService(Android.C2dmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     androidService = new Android.C2dmPushService(channelSettings, serviceSettings);
     androidService.Events.RegisterProxyHandler(this.Events);
 }
コード例 #21
0
ファイル: PushService.cs プロジェクト: nuttapol/PushSharp
 public void StartWindowsPushService(Windows.WindowsPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     winService = new Windows.WindowsPushService(channelSettings, serviceSettings);
     winService.Events.RegisterProxyHandler(this.Events);
 }
コード例 #22
0
 public ChannelScalerImpl(PushServiceSettings settings, ChannelLoadBalancer loadBalancer)
 {
     this.ServiceSettings = settings;
     this.ChannelLoadBalancer = loadBalancer;
 }
コード例 #23
0
 public BlackberryPushService(
     BlackberryPushChannelSettings channelSettings, PushServiceSettings serviceSettings)
     : base(new BlackberryPushChannelFactory(channelSettings), serviceSettings)
 {
 }
コード例 #24
0
 public WindowsPhonePushService(
     WindowsPhonePushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
     : base(new WindowsPhoneChannelFactory(channelSettings), serviceSettings)
 {
 }
コード例 #25
0
ファイル: PushService.cs プロジェクト: nuttapol/PushSharp
 public void StartGoogleCloudMessagingPushService(Android.GcmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     gcmService = new Android.GcmPushService(channelSettings, serviceSettings);
     gcmService.Events.RegisterProxyHandler(this.Events);
 }
コード例 #26
0
ファイル: GcmPushService.cs プロジェクト: rajwilkhu/PushSharp
 public GcmPushService(GcmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
     : base(channelSettings, serviceSettings)
 {
 }