[aerogear-dev] Internal 'API' change for the different Senders?

Sebastien Blanc scm.blanc at gmail.com
Fri May 23 05:48:26 EDT 2014


Looks like a great enhancement to me , +1 !



On Fri, May 23, 2014 at 11:24 AM, Matthias Wessendorf <matzew at apache.org>wrote:

> Hello,
>
> looking at the Senders, I'd like to re-introduce an interface which they
> all extend:
>
> /**
>  * Each implementation deals with the specific of the underlying push network, including transforming the content of the
>  * {@link UnifiedPushMessage} to the proper message format of the actual push network and maintaining the connection to it.
>  */
> public interface PushNotificationSender {
>
>     /**
>      * Sends the {@link UnifiedPushMessage} to the given clients, identified by a collection of tokens, the underlying push network.
>      *
>      * @param variant contains details for the underlying push network, e.g. API Keys/Ids
>      * @param clientIdentifiers platform specific collection of client identifiers
>      * @param pushMessage payload to be send to the given clients
>      * @param senderCallback invoked after submitting the request to the underlying push network to indicate the status
>      *                       of the request (<code>success</code> or <code>error</code>
>      */
>     void sendPushMessage(Variant variant, Collection<String> clientIdentifiers, UnifiedPushMessage pushMessage, NotificationSenderCallback senderCallback);
> }
>
> What's really new here is passing in a 'callback'
> (NotificationSenderCallback) that gives the caller of an
> PushNotificationSender implementation a hint if we could submit the
> messages to the push network, or not:
>
> /**
>  * A simple Callback interface used when sending {@link org.jboss.aerogear.unifiedpush.message.UnifiedPushMessage} to
>  * an actual push network.
>  */
> public interface NotificationSenderCallback {
>
>     /**
>      * Simple indicator which will be called on a successful to deliver to the push network. However, the invocation of
>      * this callback does <b>NOT</b> mean the messages have been sent out to the mobile devices. The invocation simply means
>      * the {@link org.jboss.aerogear.unifiedpush.message.sender.PushNotificationSender} was able to send the messages to
>      * the push network for its further processing
>      */
>     void onSuccess();
>
>     /**
>      * Simple indicator which will be called on any type of error that occurred while sending the payload to the
>      * underlying push network.
>      */
>     void onError();
> }
>
> The reason why I'd like to do that is this give me better access to the
> state of the request (for submitting messages). That is generally a nice
> thing to be aware of the request-state. For our new "push history" overview
> (see related threads), this comes handy, as I have all the needed
> information in a more centralized place, instead of injecting a 'Metrics'
> service into all the PushNotificationSender implementations:
>
> ...
> // save APNs-delivery timestamp to metrics-database
> // save number of APNs tokens to metrics-database
> myAPNsSender.sendPushMessage(variant, collectionOfTokensForVariant, upsMessage, new NotificationSenderCallback() {
>     @Override
>     public void onSuccess() {
>         // save success status for the given variant to metrics-database
>     }
>
>     @Override
>     public void onError() {
>         // save failure status for the given variant to metrics-database
>     }
> });
>
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20140523/b026a065/attachment.html 


More information about the aerogear-dev mailing list