public static void RegisterWindowsService(this PushBroker broker, WindowsPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
        {
            var service = new WindowsPushService(new WindowsPushChannelFactory(), channelSettings, serviceSettings);

            broker.RegisterService<WindowsRawNotification>(service);
            broker.RegisterService<WindowsTileNotification>(service);
            broker.RegisterService<WindowsToastNotification>(service);
            broker.RegisterService<WindowsBadgeNumericNotification>(service);
            broker.RegisterService<WindowsBadgeGlyphNotification>(service);
        }
        public static void RegisterWindowsPhoneService(this PushBroker broker, WindowsPhonePushChannelSettings channelSettings = null, PushServiceSettings serviceSettings = null)
        {
            var service = new WindowsPhonePushService(new WindowsPhonePushChannelFactory(), channelSettings, serviceSettings);

            broker.RegisterService<WindowsPhoneCycleTileNotification>(service);
            broker.RegisterService<WindowsPhoneFlipTileNotification>(service);
            broker.RegisterService<WindowsPhoneIconicTileNotification>(service);
            broker.RegisterService<WindowsPhoneTileNotification>(service);
            broker.RegisterService<WindowsPhoneToastNotification>(service);
            broker.RegisterService<WindowsPhoneRawNotification>(service);
        }
Ejemplo n.º 3
0
		private Mock<PushServiceBase> MockUpService(PushServiceSettings serviceSettings,
		                                            Action<INotification, SendNotificationCallbackDelegate> callback)
		{
			var mockChanSettings = new Mock<IPushChannelSettings>();

			var mockChanFactory = new Mock<IPushChannelFactory>();
			mockChanFactory.Setup(cf => cf.CreateChannel(It.IsAny<IPushChannelSettings>()))
			               .Returns(() => MockUpChannel(callback).Object);

			var mockPushService = new Mock<PushServiceBase>(mockChanFactory.Object, mockChanSettings.Object, serviceSettings);
			mockPushService.Setup(ps => ps.BlockOnMessageResult).Returns(true);

			return mockPushService;
		}
Ejemplo n.º 4
0
 public static void RegisterGcmService(this PushBroker broker, AdmPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     broker.RegisterService<AdmNotification>(new AdmPushService(new AdmPushChannelFactory(), channelSettings, serviceSettings));
 }
Ejemplo n.º 5
0
		public void TestNotifications(List<GcmNotification> notifications,
		                              List<GcmMessageResponseFilter> responseFilters,
		                              Action<object, INotification> sentCallback,
		                              Action<object, INotification, Exception> failedCallback,
		                              Action<object, string, string, INotification> subscriptionChangedCallback,
		                              Action<object, string, DateTime, INotification> subscriptionExpiredCallback)
		{
			testPort++;

			int pushFailCount = 0;
			int pushSuccessCount = 0;
			
			int serverReceivedCount = 0;
			int serverReceivedFailCount = 0;
			int serverReceivedSuccessCount = 0;

		
			var server = new TestServers.GcmTestServer();

			server.MessageResponseFilters.AddRange(responseFilters);

			server.Start(testPort, response => {
				serverReceivedCount += (int)response.NumberOfCanonicalIds;
				serverReceivedSuccessCount += (int) response.NumberOfSuccesses;
				serverReceivedFailCount += (int) response.NumberOfFailures;
			});


		    var svcSettings = new PushServiceSettings() {AutoScaleChannels = false, Channels = 1};
			
			var settings = new GcmPushChannelSettings("SENDERAUTHTOKEN");
			settings.OverrideUrl("http://localhost:" + (testPort) + "/");
           
			var push = new GcmPushService(settings, svcSettings);
			push.OnNotificationSent += (sender, notification1) => {
				pushSuccessCount++;
				sentCallback(sender, notification1);
			};
			push.OnNotificationFailed += (sender, notification1, error) => {
				pushFailCount++;
				failedCallback(sender, notification1, error);
			};
			push.OnDeviceSubscriptionChanged += (sender, oldSubscriptionId, newSubscriptionId, notification) => subscriptionChangedCallback(sender, oldSubscriptionId, newSubscriptionId, notification);
			push.OnDeviceSubscriptionExpired += (sender, expiredSubscriptionId, expirationDateUtc, notification) => subscriptionExpiredCallback(sender, expiredSubscriptionId, expirationDateUtc, notification);


			foreach (var n in notifications)
				push.QueueNotification(n);

			push.Stop();

            Console.WriteLine("Avg Queue Wait Time: " + push.AverageQueueWaitTime + " ms");
            Console.WriteLine("Avg Send Time: " + push.AverageSendTime + " ms");

			push.Dispose();
			
			server.Dispose();
			//waitServerFinished.WaitOne();
			
			Console.WriteLine("TEST-> DISPOSE.");
		}
 public static void RegisterFacebookService(this PushBroker broker, FacebookPushChannelSettings channelSettings, PushServiceSettings serviceSettings = null)
 {
     broker.RegisterService<FacebookNotification>(new FacebookPushService(new FacebookPushChannelFactory(), channelSettings, serviceSettings));
 }
Ejemplo n.º 7
0
		public void TestNotifications(int toQueue, int expectSuccessful, int expectFailed, int[] idsToFail = null, bool waitForScaling = false, bool autoScale = false)
		{
			var testServer = new ApnsNodeTestServer ("http://localhost:8888/");
			testServer.Reset ();
			testServer.Setup (idsToFail ?? new int[] {});

			var started = DateTime.UtcNow;

			int pushFailCount = 0;
			int pushSuccessCount = 0;

			AppleNotification.ResetIdentifier ();

			var settings = new ApplePushChannelSettings(false, appleCert, "pushsharp", true);
			settings.OverrideServer("localhost", 2195);
			settings.SkipSsl = true;
			settings.MillisecondsToWaitBeforeMessageDeclaredSuccess = 5000;

			var serviceSettings = new PushServiceSettings();

			if (!autoScale)
			{
				serviceSettings.AutoScaleChannels = false;
				serviceSettings.Channels = 1;
			}

			var push = new ApplePushService(settings, serviceSettings);
			push.OnNotificationFailed += (sender, notification1, error) => {
				Console.WriteLine("NOTIFICATION FAILED: " + ((AppleNotification)notification1).Identifier);
				pushFailCount++;
			};
			push.OnNotificationSent += (sender, notification1) => {
				pushSuccessCount++;
			};
			push.OnNotificationRequeue += (sender, e) => {
				Console.WriteLine("REQUEUE: " + ((AppleNotification)e.Notification).Identifier);
			};

			for (int i = 0; i < toQueue; i++)
			{
				var n = new AppleNotification("aff441e214b2b2283df799f0b8b16c17a59b7ac077e2867ea54ebf6086e55866").WithAlert("Test");

				push.QueueNotification(n);
			}

			if (waitForScaling)
			{
				while (push.QueueLength > 0)
					Thread.Sleep(500);

				Console.WriteLine("Sleeping 3 minutes for autoscaling...");
				Thread.Sleep(TimeSpan.FromMinutes(3));

				Console.WriteLine("Channel Count: " + push.ChannelCount);
				Assert.IsTrue(push.ChannelCount <= 1);
			}

			push.Stop();
			push.Dispose();

			Console.WriteLine("Avg Queue Wait Time: " + push.AverageQueueWaitTime + " ms");
			Console.WriteLine("Avg Send Time: " + push.AverageSendTime + " ms");

			var span = DateTime.UtcNow - started;

			var info = testServer.GetInfo ();

			Console.WriteLine ("Test Time: " + span.TotalMilliseconds + " ms");
			Console.WriteLine ("Client Failed: {0} Succeeded: {1} Sent: {2}", pushFailCount, pushSuccessCount, toQueue);
			Console.WriteLine ("Server Failed: {0} Succeeded: {1} Received: {2} Discarded: {3}", info.FailedIds.Length, info.SuccessIds.Length, info.Received, info.Discarded);

			//Assert.AreEqual(toQueue, info.Received, "Server - Received Count");
			Assert.AreEqual(expectFailed, info.FailedIds.Length, "Server - Failed Count");
			Assert.AreEqual(expectSuccessful, info.SuccessIds.Length, "Server - Success Count");

			Assert.AreEqual(expectFailed, pushFailCount, "Client - Failed Count");
			Assert.AreEqual(expectSuccessful, pushSuccessCount, "Client - Success Count");
		}