Package org.jboss.aerogear.unifiedpush

Examples of org.jboss.aerogear.unifiedpush.SenderClient


        String rootServerURL = "https://" + pluginComponent.targetHost;
        if (pluginComponent.port!=80) {
            rootServerURL += ":" + pluginComponent.port;
        }
        SenderClient sender = new SenderClient(rootServerURL);

        final SenderResult[] result = new SenderResult[1];
        sender.send(unifiedMessage, new MessageResponseCallback() {

              @Override
              public void onError(Throwable throwable) {

                result[0] = SenderResult.getSimpleFailure(throwable.getMessage());
View Full Code Here


    public UnifiedMessageBlueprint generate() {
        return message();
    }*/

    public SenderRequest send(UnifiedMessage message) {
        SenderClient senderClient = new SenderClient.Builder(getSession().getBaseUrl().toExternalForm())
                .customTrustStore("setup/aerogear.truststore", null, "aerogear")
                .build();

        final CountDownLatch latch = new CountDownLatch(1);
        final AtomicInteger statusCode = new AtomicInteger(-1);

        MessageResponseCallback callback = new MessageResponseCallback() {
            @Override
            public void onComplete(int status) {
                statusCode.set(status);
                latch.countDown();
            }

            @Override
            public void onError(Throwable throwable) {
                throw new RuntimeException(throwable);
            }
        };

        senderClient.send(message, callback);

        try {
            latch.await(5000, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            e.printStackTrace();
View Full Code Here

         return HandleStatus.NO_MATCH;
      }

      String alert = message.getTypedProperties().getProperty(AeroGearConstants.AEROGEAR_ALERT).toString();

      JavaSender sender = new SenderClient(endpoint);

      UnifiedMessage.Builder builder = new UnifiedMessage.Builder();

      builder.pushApplicationId(applicationId)
         .masterSecret(applicationMasterSecret)
         .alert(alert);

      String sound = message.containsProperty(AeroGearConstants.AEROGEAR_SOUND) ? message.getStringProperty(AeroGearConstants.AEROGEAR_SOUND) : this.sound;

      if (sound != null)
      {
         builder.sound(sound);
      }

      String badge = message.containsProperty(AeroGearConstants.AEROGEAR_BADGE) ? message.getStringProperty(AeroGearConstants.AEROGEAR_BADGE) : this.badge;

      if (badge != null)
      {
         builder.badge(badge);
      }

      Integer ttl = message.containsProperty(AeroGearConstants.AEROGEAR_TTL) ? message.getIntProperty(AeroGearConstants.AEROGEAR_TTL) : this.ttl;

      if (ttl != null)
      {
         builder.timeToLive(ttl);
      }

      String variantsString = message.containsProperty(AeroGearConstants.AEROGEAR_VARIANTS) ? message.getStringProperty(AeroGearConstants.AEROGEAR_VARIANTS) : null;

      String[] variants = variantsString != null ? variantsString.split(",") : this.variants;

      if (variants != null)
      {
         builder.variants(Arrays.asList(variants));
      }

      String aliasesString = message.containsProperty(AeroGearConstants.AEROGEAR_ALIASES) ? message.getStringProperty(AeroGearConstants.AEROGEAR_ALIASES) : null;

      String[] aliases = aliasesString != null ? aliasesString.split(",") : this.aliases;

      if (aliases != null)
      {
         builder.aliases(Arrays.asList(aliases));
      }

      String deviceTypesString = message.containsProperty(AeroGearConstants.AEROGEAR_DEVICE_TYPES) ? message.getStringProperty(AeroGearConstants.AEROGEAR_DEVICE_TYPES) : null;

      String[] deviceTypes = deviceTypesString != null ? deviceTypesString.split(",") : this.deviceTypes;

      if (deviceTypes != null)
      {
         builder.deviceType(Arrays.asList(deviceTypes));
      }

      Set<SimpleString> propertyNames = message.getPropertyNames();

      for (SimpleString propertyName : propertyNames)
      {
         if (propertyName.toString().startsWith("AEROGEAR_") && !AeroGearConstants.ALLOWABLE_PROPERTIES.contains(propertyName))
         {
            Object property = message.getTypedProperties().getProperty(propertyName);
            builder.attribute(propertyName.toString(), property.toString());
         }
      }

      UnifiedMessage unifiedMessage = builder.build();

      sender.send(unifiedMessage, this);

      if (handled)
      {
         reference.acknowledge();
         return HandleStatus.HANDLED;
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.unifiedpush.SenderClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.