Example #1
0
        public WnsServiceConnection(WnsConfiguration configuration, WnsAccessTokenManager accessTokenManager)
        {
            AccessTokenManager = accessTokenManager;
            Configuration      = configuration;

            http = new HttpClient();
            http.DefaultRequestHeaders.ExpectContinue = false; //Disable expect-100 to improve latency
        }
Example #2
0
        public WnsServiceConnection(WnsConfiguration configuration)
        {
            Configuration = configuration;

            //TODO: Microsoft recommends we disable expect-100 to improve latency
            // Not sure how to do this in httpclient
            http = new HttpClient();
        }
Example #3
0
        public void WNS_Send_Mutiple ()
        {
            var succeeded = 0;
            var failed = 0;
            var attempted = 0;

            var config = new WnsConfiguration (Settings.Instance.WnsPackageName,
                Settings.Instance.WnsPackageSid,
                Settings.Instance.WnsClientSecret);

            var broker = new WnsServiceBroker (config);
            broker.OnNotificationFailed += (notification, exception) => {
                failed++;
            };
            broker.OnNotificationSucceeded += (notification) => {
                succeeded++;
            };

            broker.Start ();

            foreach (var uri in Settings.Instance.WnsChannelUris) {
                for (var i = 1; i <= 3; i++) {
                    attempted++;
                    broker.QueueNotification (new WnsToastNotification {
                            ChannelUri = uri,
                            Payload = XElement.Parse(@"
                                <toast>
                                    <visual>
                                        <binding template=""ToastText01"">
                                            <text id=""1"">WNS_Send_Multiple " + i.ToString() + @"</text>
                                        </binding>  
                                    </visual>
                                </toast>
                            ")
                        });
                }
            }

            broker.Stop ();

            Assert.AreEqual (attempted, succeeded);
            Assert.AreEqual (0, failed);
        }
 public WnsAccessTokenManager(WnsConfiguration configuration)
 {
     http          = new HttpClient();
     Configuration = configuration;
 }
Example #5
0
 public WnsServiceConnection(WnsConfiguration configuration, WnsAccessTokenManager accessTokenManager)
 {
     AccessTokenManager = accessTokenManager;
     Configuration      = configuration;
 }
Example #6
0
 public WnsServiceBroker(WnsConfiguration configuration) : base(new WnsServiceConnectionFactory(configuration))
 {
 }
Example #7
0
 public WnsServiceConnectionFactory(WnsConfiguration configuration)
 {
     wnsAccessTokenManager = new WnsAccessTokenManager(configuration);
     Configuration         = configuration;
 }
 public WnsAccessTokenManager (WnsConfiguration configuration)
 {
     http = new HttpClient ();
     Configuration = configuration;
 }
Example #9
0
 public WnsServiceConnectionFactory(WnsConfiguration configuration)
 {
     Configuration = configuration;
 }