<div dir="ltr">Looks like a great enhancement to me , +1 ! <div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 23, 2014 at 11:24 AM, Matthias Wessendorf <span dir="ltr"><<a href="mailto:matzew@apache.org" target="_blank">matzew@apache.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:15.454545021057129px;line-height:23.18181800842285px;margin-top:0px!important">
Hello,</p><p style="margin:15px 0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:15.454545021057129px;line-height:23.18181800842285px">looking at the Senders, I'd like to re-introduce an interface which they all extend:</p>
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;margin-top:15px;margin-bottom:15px;border:1px solid rgb(221,221,221);line-height:19px;overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(248,248,248)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;padding:0px;word-wrap:normal;display:inline;line-height:inherit;background:transparent">/**
* 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);
}
</code></pre><p style="margin:15px 0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:15.454545021057129px;line-height:23.18181800842285px">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:</p>
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;margin-top:15px;margin-bottom:15px;border:1px solid rgb(221,221,221);line-height:19px;overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(248,248,248)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;padding:0px;word-wrap:normal;display:inline;line-height:inherit;background:transparent">/**
* 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();
}
</code></pre><p style="margin:15px 0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:15.454545021057129px;line-height:23.18181800842285px">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:</p>
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;margin-top:15px;margin-bottom:15px;border:1px solid rgb(221,221,221);line-height:19px;overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51);background-color:rgb(248,248,248)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;padding:0px;word-wrap:normal;display:inline;line-height:inherit;background:transparent">...
// 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
}
});</code></pre><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>
sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>
twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</font></span></div>
<br>_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br></blockquote></div><br></div>