Esempio n. 1
0
    private static void MakeInternalRegistration( string channel, PushNotificationsBinding pushNotificationsBinding, AsyncCallback<string> callback )
    {
      var httpNotificationChannel = HttpNotificationChannel.Find( channel ) ??
                                    new HttpNotificationChannel(channel, Backendless.URL);

      if(httpNotificationChannel.ConnectionStatus.Equals( ChannelConnectionStatus.Connected ))
        ProceedRegistration( httpNotificationChannel, callback );
      else
      {
        httpNotificationChannel.ConnectionStatusChanged +=
          _onConnectionStatusChangedHandler = delegate( object sender, NotificationChannelConnectionEventArgs args )
            {
              if( args.ConnectionStatus.Equals( ChannelConnectionStatus.Connected ) )
              {
                ProceedRegistration( httpNotificationChannel, callback );
                httpNotificationChannel.ConnectionStatusChanged -= _onConnectionStatusChangedHandler;
              }
            };
        httpNotificationChannel.Open();
      }

      if(pushNotificationsBinding != null)
        pushNotificationsBinding.ApplyTo( httpNotificationChannel );
      
      httpNotificationChannel.ErrorOccurred +=
        ( sender, args ) => callback.ErrorHandler.Invoke( new BackendlessFault( args.Message ) );
    }
Esempio n. 2
0
        private static void MakeInternalRegistration(string channel, PushNotificationsBinding pushNotificationsBinding, AsyncCallback <string> callback)
        {
            var httpNotificationChannel = HttpNotificationChannel.Find(channel);

            if (httpNotificationChannel == null)
            {
                httpNotificationChannel = new HttpNotificationChannel(channel, Backendless.URL);
                httpNotificationChannel.ChannelUriUpdated += (sender, args) => ProceedRegistration(httpNotificationChannel, callback);
                httpNotificationChannel.Open();
            }
            else
            {
                httpNotificationChannel.ChannelUriUpdated += (sender, args) => ProceedRegistration(httpNotificationChannel, callback);
            }

            if (pushNotificationsBinding != null)
            {
                pushNotificationsBinding.ApplyTo(httpNotificationChannel);
            }


/*
 *    if(httpNotificationChannel.ConnectionStatus.Equals( ChannelConnectionStatus.Connected ))
 *      ProceedRegistration( httpNotificationChannel, callback );
 *    else
 *    {
 *      httpNotificationChannel.ConnectionStatusChanged +=
 *        _onConnectionStatusChangedHandler = delegate( object sender, NotificationChannelConnectionEventArgs args )
 *          {
 *            if( args.ConnectionStatus.Equals( ChannelConnectionStatus.Connected ) )
 *            {
 *              ProceedRegistration( httpNotificationChannel, callback );
 *              httpNotificationChannel.ConnectionStatusChanged -= _onConnectionStatusChangedHandler;
 *            }
 *          };
 *      httpNotificationChannel.Open();
 *    }
 *
 *    if(pushNotificationsBinding != null)
 *      pushNotificationsBinding.ApplyTo( httpNotificationChannel );
 * */

            httpNotificationChannel.ErrorOccurred +=
                (sender, args) => callback.ErrorHandler.Invoke(new BackendlessFault(args.Message));
        }