com.relayrides.pushy.apns
Interface ApnsConnectionListener<T extends ApnsPushNotification>

All Known Implementing Classes:
PushManager

public interface ApnsConnectionListener<T extends ApnsPushNotification>

An ApnsConnectionListener receives lifecycle events from ApnsConnection instances. Handler methods are called from IO threads in the connection's event loop, and as such handler method implementations must not perform blocking operations. Blocking operations should be dispatched in separate threads.

Author:
Jon Chambers

Method Summary
 void handleConnectionClosure(ApnsConnection<T> connection)
          Indicates that the given connection has disconnected from the previously-connected APNs gateway and can no longer send push notifications.
 void handleConnectionFailure(ApnsConnection<T> connection, Throwable cause)
          Indicates that the given connection attempted to connect to an APNs gateway, but failed.
 void handleConnectionSuccess(ApnsConnection<T> connection)
          Indicates that the given connection successfully connected to an APNs gateway and is ready to send push notifications.
 void handleConnectionWritabilityChange(ApnsConnection<T> connection, boolean writable)
          Indicates that the given connection has changed its writability state.
 void handleRejectedNotification(ApnsConnection<T> connection, T rejectedNotification, RejectedNotificationReason reason)
          Indicates that a notification sent via the given connection was definitively rejected by the APNs gateway.
 void handleUnprocessedNotifications(ApnsConnection<T> connection, Collection<T> unprocessedNotifications)
          Indicates that notifications that had previously been sent to an APNs gateway by the given connection were not processed by the gateway and should be sent again later.
 void handleWriteFailure(ApnsConnection<T> connection, T notification, Throwable cause)
          Indicates that the given connection failed to send a push notification to an APNs gateway.
 

Method Detail

handleConnectionSuccess

void handleConnectionSuccess(ApnsConnection<T> connection)
Indicates that the given connection successfully connected to an APNs gateway and is ready to send push notifications.

Parameters:
connection - the connection that completed its connection attempt

handleConnectionFailure

void handleConnectionFailure(ApnsConnection<T> connection,
                             Throwable cause)
Indicates that the given connection attempted to connect to an APNs gateway, but failed.

Parameters:
connection - the connection that failed to connect to an APNs gateway
cause - the cause of the failure

handleConnectionWritabilityChange

void handleConnectionWritabilityChange(ApnsConnection<T> connection,
                                       boolean writable)
Indicates that the given connection has changed its writability state. Attempts to write to an unwritable connection are guaranteed to fail and should be avoided. Successful connections begin in a writable state.

Parameters:
connection - the connection whose writability has changed
writable - true if the connection has become writable or false if it has become unwritable

handleConnectionClosure

void handleConnectionClosure(ApnsConnection<T> connection)
Indicates that the given connection has disconnected from the previously-connected APNs gateway and can no longer send push notifications. This may happen either when the connection is closed locally or when the APNs gateway closes the connection remotely. This method will only be called if the connection had previously succeeded and completed a TLS handshake.

Parameters:
connection - the connection that has been disconnected and is no longer active

handleWriteFailure

void handleWriteFailure(ApnsConnection<T> connection,
                        T notification,
                        Throwable cause)
Indicates that the given connection failed to send a push notification to an APNs gateway. This indicates a local failure; notifications passed to this method were never transmitted to the APNs gateway, and failures of this kind generally represent temporary I/O problems (rather than permanent rejection by the gateway), and it is generally safe to try to send the failed notifications again later.

Parameters:
connection - the connection that attempted to deliver the notification
notification - the notification that could not be written
cause - the cause of the write failure

handleRejectedNotification

void handleRejectedNotification(ApnsConnection<T> connection,
                                T rejectedNotification,
                                RejectedNotificationReason reason)
Indicates that a notification sent via the given connection was definitively rejected by the APNs gateway. When an APNs gateway rejects a notification, the rejection should be considered a permanent failure and the notification should not be sent again. The APNs gateway will close the connection after rejecting a notification, and all notifications sent after the rejected notification were not processed by the gateway and should be re-sent later.

Parameters:
connection - the connection that sent the notification that was rejected
rejectedNotification - the notification that was rejected
reason - the reason for the rejection
See Also:
handleConnectionClosure(ApnsConnection), handleUnprocessedNotifications(ApnsConnection, Collection)

handleUnprocessedNotifications

void handleUnprocessedNotifications(ApnsConnection<T> connection,
                                    Collection<T> unprocessedNotifications)
Indicates that notifications that had previously been sent to an APNs gateway by the given connection were not processed by the gateway and should be sent again later. This generally happens after a notification has been rejected by the gateway, but may also happen when a connection is closed gracefully by Pushy or closed remotely by the APNs gateway without a rejected notification.

Parameters:
connection - the connection that sent the notifications that were not processed
unprocessedNotifications - the notifications known to have not been processed by the APNs gateway


Copyright © 2013–2014 RelayRides. All rights reserved.