-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection failure listener (fixes #32) #51
Connection failure listener (fixes #32) #51
Conversation
…into connection_failure_listener
* @param pushManager the push manager that failed to open a connection | ||
* @param cause the cause for the connection failure | ||
*/ | ||
void handleFailedConnection(PushManager<? extends T> pushManager, Throwable cause); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not PushManager<T> pushManager
since T is only defined as extending ApnsPushNotification
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, let's say you have the following push notification subclasses:
FancyApnsPushNotification extends SimpleApnsPushNotification
ShinyApnsPushNotification extends SimpleApnsPushNotification
You might have two PushManager
instances in your app, each with one of those two push notification subclasses. You could then use a single listener typed for the base class to listen for failures on both push managers. It might look something like this:
public class MyFailedConnectionListener implements FailedConnectionListener<SimpleApnsPushNotification> {
public void handleFailedConnection(final PushManager<? extends SimpleApnsPushNotification> pushManager, final Throwable cause) {
// …
}
}
That would work because both push managers would be typed to subclasses of SimpleApnsPushNotification
, and thus would match PushManager<? extends SimpleApnsPushNotification>
. If we just did <T>
for the push manager argument, we'd have to match the type exactly and would lose some flexibility. Does that make any sense?
Conflicts: src/main/java/com/relayrides/pushy/apns/PushManager.java src/test/java/com/relayrides/pushy/apns/PushManagerTest.java
Conflicts: src/main/java/com/relayrides/pushy/apns/PushManager.java
We are having issues where if one of our clients uploads a bad cert pushy will continually try to reconnect, will this PR be merged at some point? |
Yes. We have a couple high-priority things to resolve this week, but reviewing/shipping v0.3 (this included) is high on the to-do list. |
Conflicts: src/main/java/com/relayrides/pushy/apns/PushManager.java
👍 still looks good |
…into connection_failure_listener
Conflicts: src/main/java/com/relayrides/pushy/apns/PushManager.java
Conflicts: src/main/java/com/relayrides/pushy/apns/PushManager.java
…into connection_failure_listener
Connection failure listener (fixes #32)
This change introduces the
FailedConnectionListener
interface. Applications using Pushy can register connection failure listeners to watch for connection failures that are unlikely to be resolved by future reconnection attempts (i.e.SSLHandshakeException
s) and respond accordingly. There are a couple other changes rolled up in here, too:PushManager
argument for rejected notification listeners, so listeners associated with multiple push managers can tell which one had the rejection.ExecutorService
externally-configurable; failed connection listeners and rejected notification listeners will be called by tasks from that service.