当前位置: 首页>>代码示例>>C#>>正文


C# HttpNotificationChannel.Open方法代码示例

本文整理汇总了C#中HttpNotificationChannel.Open方法的典型用法代码示例。如果您正苦于以下问题:C# HttpNotificationChannel.Open方法的具体用法?C# HttpNotificationChannel.Open怎么用?C# HttpNotificationChannel.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpNotificationChannel的用法示例。


在下文中一共展示了HttpNotificationChannel.Open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AcquireToken

	    private async void AcquireToken()
	    {
	        var currentChannel = HttpNotificationChannel.Find(ChannelName);
		    if (currentChannel == null)
		    {
			    currentChannel = new HttpNotificationChannel(ChannelName);
				currentChannel.Open();
				currentChannel.BindToShellToast();
				currentChannel.ChannelUriUpdated += (sender, args) =>
				{
					RegisterToken(currentChannel.ChannelUri.AbsoluteUri);
				};

			    if (currentChannel.ChannelUri == null)
			    {
				    await Task.Delay(200);
					if(currentChannel.ChannelUri == null)
						return;
			    }

			    RegisterToken(currentChannel.ChannelUri.AbsoluteUri);
		    }
		    else
		    {
				currentChannel.ChannelUriUpdated += (sender, args) =>
				{
					RegisterToken(currentChannel.ChannelUri.AbsoluteUri);
				};
			}

			currentChannel.ShellToastNotificationReceived += OnNotificationReceived;
		}
开发者ID:QRyptoWire,项目名称:qrypto-wire,代码行数:32,代码来源:PhoneService.cs

示例2: Init

        public void Init()
        {
            try
            {
                //First, try to pick up existing channel
                httpChannel = HttpNotificationChannel.Find(channelName);

                if (null != httpChannel)
                {
                    SubscribeToChannelEvents();

                    SubscribeToService();

                    SubscribeToNotifications();
                }
                else
                {
                    httpChannel = new HttpNotificationChannel(channelName, "BlandCAPITAL.Shared.FinanceService");

                    SubscribeToChannelEvents();

                    httpChannel.Open();
                }
            }
            catch
            {

            }
        }
开发者ID:Newbourne,项目名称:CAPITAL,代码行数:29,代码来源:NotificationService.cs

示例3: AcquirePushChannel

        private void AcquirePushChannel()
        {
            CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");

            if (CurrentChannel == null)
            {
                CurrentChannel = new HttpNotificationChannel("MyPushChannel");
                CurrentChannel.Open();
                CurrentChannel.BindToShellToast();
            }

            CurrentChannel.ChannelUriUpdated +=
                new EventHandler<NotificationChannelUriEventArgs>(async (o, args) =>
                {
                    MobileServiceClient client = todoItemManager.GetClient;

                    // Register for notifications using the new channel
                    const string template =
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?><wp:Notification " +
                    "xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1>$(message)</wp:Text1></wp:Toast></wp:Notification>";

                    await client.GetPush()
                        .RegisterTemplateAsync(CurrentChannel.ChannelUri.ToString(), template, "mytemplate");
                });
        }
开发者ID:fellipetenorio,项目名称:mobile-services-samples,代码行数:25,代码来源:App.xaml.cs

示例4: RegisterPushNotifications

        public void RegisterPushNotifications()
        {
            if (pushChannel != null) return;

            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null) {
                pushChannel = new HttpNotificationChannel(channelName, "PositiveSSL CA");

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated;
                pushChannel.ErrorOccurred += PushChannel_ErrorOccurred;
                pushChannel.HttpNotificationReceived += PushChannel_HttpNotificationReceived;

                pushChannel.Open();
                pushChannel.BindToShellToast();
                pushChannel.BindToShellTile();
            } else {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated;
                pushChannel.ErrorOccurred += PushChannel_ErrorOccurred;
                pushChannel.HttpNotificationReceived += PushChannel_HttpNotificationReceived;
            }

            if (UriUpdated != null && pushChannel.ChannelUri != null) {
                UriUpdated(pushChannel.ChannelUri.ToString());
            }
        }
开发者ID:allanfreitas,项目名称:gtalkchat,代码行数:29,代码来源:PushHelper.cs

示例5: open_Click

        private void open_Click(object sender, RoutedEventArgs e)
        {
            var channel = HttpNotificationChannel.Find("TestChannel");

            if (channel == null || channel.ChannelUri == null)
            {
                if(channel != null)
                {
                    channel.Close();
                    channel.Dispose();
                }

                channel = new HttpNotificationChannel("TestChannel");
                channel.ChannelUriUpdated += channel_ChannelUriUpdated;
                channel.ErrorOccurred += channel_ErrorOccurred;
                channel.Open();
            }
            else
            {
                channel.ErrorOccurred += channel_ErrorOccurred;
                Debug.WriteLine(channel.ChannelUri.AbsoluteUri);
            }

            channel.ShellToastNotificationReceived += channel_ShellToastNotificationReceived;

            if(!channel.IsShellToastBound) channel.BindToShellToast();
        }
开发者ID:follesoe,项目名称:WP7Demos,代码行数:27,代码来源:PushNotification.xaml.cs

示例6: MainPage

        // Constructor
        public MainPage()
        {
            HttpNotificationChannel pushChannel;
            String channelName = "ToastSampleChannel";
            InitializeComponent();
            pushChannel = HttpNotificationChannel.Find(channelName);
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                pushChannel.Open();
                pushChannel.BindToShellToast();
            }
            else
            {
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);
                pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived);
                System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
                MessageBox.Show(String.Format("Channel uri is {0}", pushChannel.ChannelUri.ToString()));
            }

        }
开发者ID:sangnvus,项目名称:2015FALLIS01,代码行数:26,代码来源:MainPage.xaml.cs

示例7: OnInit

        public override void OnInit()
        {
            configHandler.LoadAppPackageConfig();

            string channelName = "UAPush";

            // Try to find the push channel.
            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                pushChannel.Open();

                // Bind this new channel for toast events.
                pushChannel.BindToShellToast();
            }
            else
            {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                this.RegisterDevice(pushChannel.ChannelUri);
            }
        }
开发者ID:Endare,项目名称:phonegap-push-wp8,代码行数:32,代码来源:PushNotificationPlugin.cs

示例8: DoConnect

        private void DoConnect()
        {
            try
            {

                httpChannel = HttpNotificationChannel.Find(channelName);

                if (null != httpChannel)
                {

                    SubscribeToChannelEvents();

                    SubscribeToService();

                    SubscribeToNotifications();

                    Dispatcher.BeginInvoke(() => UpdateStatus("Channel recovered"));
                }
                else
                {

                    httpChannel = new HttpNotificationChannel(channelName, "HOLWeatherService");

                    SubscribeToChannelEvents();

                    httpChannel.Open();
                    Dispatcher.BeginInvoke(() => UpdateStatus("Channel open requested"));
                }
            }
            catch (Exception ex)
            {
                Dispatcher.BeginInvoke(() => UpdateStatus("Channel error: " + ex.Message));
            }
        }
开发者ID:nikhildhawan,项目名称:c2dm,代码行数:34,代码来源:MainPage.xaml.cs

示例9: SetupNotificationChannel

        public void SetupNotificationChannel()
        {
            if (!InternetIsAvailable()) return;
            channel = HttpNotificationChannel.Find(channelName);

            if (channel == null)
            {
                channel = new HttpNotificationChannel(channelName);
                HookupHandlers();
                channel.Open();
            }
            else
            {
                HookupHandlers();
                try
                {
                    channelUri = channel.ChannelUri.ToString();
                    apiMethodRequest.SendRequest(VkApi.Authorization.AccessToken, "account.registerDevice", new Dictionary<string, string>() { { "token", channelUri } });
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
开发者ID:mikejan,项目名称:EntacikGorc,代码行数:25,代码来源:Notifications.cs

示例10: Connect

        public void Connect()
        {
            try
            {
                httpChannel = HttpNotificationChannel.Find(channelName);

                if (null != httpChannel)
                {
                    SubscribeToChannelEvents();
                    SubscribeToNotifications();
                    Deployment.Current.Dispatcher.BeginInvoke(() => this.UpdateStatus("Channel recovered"));
                }
                else
                {
                    httpChannel = new HttpNotificationChannel(channelName, "GeoScavChannel");
                    SubscribeToChannelEvents();
                    httpChannel.Open();
                    Deployment.Current.Dispatcher.BeginInvoke(() => this.UpdateStatus("Channel open requested"));
                }
            }
            catch (Exception ex)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => UpdateStatus("Channel error: " + ex.Message));
            }
        }
开发者ID:bdunlay,项目名称:geoscav,代码行数:25,代码来源:NotificationClient.cs

示例11: CreateNewChannel

 private HttpNotificationChannel CreateNewChannel()
 {
     var channel = HttpNotificationChannel.Find(AppContext.State.AppId);
     if (channel == null)
     {
         channel = new HttpNotificationChannel(AppContext.State.AppId);
         SubscribeToEvents(channel);
         // Open the channel
         channel.Open();
         UpdateChannelUri(channel.ChannelUri);
         // Register for tile notifications
         var whitelistedDomains = AppContext.State.Settings.PushSettings.WhitelistedDomains;
         if (whitelistedDomains.Count == 0)
             channel.BindToShellTile();
         else
             channel.BindToShellTile(new Collection<Uri>(whitelistedDomains));
         // Register for shell notifications
         channel.BindToShellToast();
     }
     else
     {
         SubscribeToEvents(channel);
         UpdateChannelUri(channel.ChannelUri);
     }
     return channel;
 }
开发者ID:appacitive,项目名称:appacitive-dotnet-sdk,代码行数:26,代码来源:SingletonPushChannel.cs

示例12: OpenChannel

        public void OpenChannel(Action<string> channelCallback)
        {
            try
            {
                _channel = HttpNotificationChannel.Find(ChannelName);
            }
            catch { }

            if (_channel != null && _channel.ChannelUri != null)
            {
                channelCallback(_channel.ChannelUri.ToString());
            }
            else
            {
                try
                {
                    _channel = new HttpNotificationChannel(ChannelName);
                    _channel.ChannelUriUpdated += (o, e) => channelCallback(e.ChannelUri.ToString());
                    _channel.Open();
                    _channel.BindToShellToast();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                }
            }
        }
开发者ID:chrisntr,项目名称:FlightsNorway,代码行数:27,代码来源:NotificationService.cs

示例13: CreatePushChannel

        // LIVE TILE CODE ADDED HERE !!!!!!!!------------------------!!!!!!!!!!!!!!!!

        private void CreatePushChannel()
        {
            // Try to find the push channel.
            pushChannel = HttpNotificationChannel.Find(channelName);

            // If the channel was not found, then create a new connection to the push service.
            if (pushChannel == null)
            {
                pushChannel = new HttpNotificationChannel(channelName);

                // Register for all the events before attempting to open the channel.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                pushChannel.Open();

                // Bind this new channel for Tile events.
                pushChannel.BindToShellTile();
            }
            else
            {
                // The channel was already open, so just register for all the events.
                pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated);
                pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred);

                // Display the URI for testing purposes. Normally, the URI would be passed back to your web service at this point.
   // hereeee uncommnt      //       System.Diagnostics.Debug.WriteLine(pushChannel.ChannelUri.ToString());
                //MessageBox.Show(String.Format("Channel Uri is {0}", pushChannel.ChannelUri.ToString()));
            }
        }
开发者ID:vbhargavmbis,项目名称:Climatica,代码行数:32,代码来源:MainPage.xaml.cs

示例14: DoConnect

 private void DoConnect()
 {
     try
     {
         //首先查看现有的频道
         httpChannel = HttpNotificationChannel.Find(channelName);
         //如果频道存在
         if (httpChannel != null)
         {
             //注册Microsoft推送通知事件
             SubscribeToChannelEvents();
             //检测Microsoft通知服务注册状态
             SubscribeToService();
             //订阅Toast和Title通知
             SubscribeToNotifications();
         }
         else
         {
             //试图创建一个新的频道
             //创建频道
             httpChannel = new HttpNotificationChannel(channelName, "PuzzleService");
             //推送通知频道创建成功
             SubscribeToChannelEvents();
             //注册Microsoft推送通知事件
             httpChannel.Open();
         }
     }
     catch (Exception ex)
     {
         //创建或恢复频道时发生异常
     }
 }
开发者ID:cityjoy,项目名称:CommonToolkit,代码行数:32,代码来源:PushMsg.cs

示例15: SetupNotificationChannel

        public void SetupNotificationChannel()
        {
            if (!InternetIsAvailable()) return;
            channel = HttpNotificationChannel.Find(channelName);

            if (channel == null)
            {
                channel = new HttpNotificationChannel(channelName);
                HookupHandlers();
                channel.Open();
            }
            else
            {
                HookupHandlers();
                try
                {
                    pushClient.RegisterPhoneAsync(WP7App1.Bootstrapper.phoneId, channel.ChannelUri.ToString(), username);
                }
                catch (Exception ex)
                {

                    throw ex;
                }
            }
        }
开发者ID:HTigran777,项目名称:iQezBan,代码行数:25,代码来源:NotificationManager.cs


注:本文中的HttpNotificationChannel.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。