/src/main/java/com/notnoop/apns/ApnsDelegate.java

http://github.com/notnoop/java-apns · Java · 92 lines · 9 code · 7 blank · 76 comment · 0 complexity · 0214bdea75a1618bd2969bc0ec51c88a MD5 · raw file

  1. /*
  2. * Copyright 2009, Mahmood Ali.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are
  7. * met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above
  12. * copyright notice, this list of conditions and the following disclaimer
  13. * in the documentation and/or other materials provided with the
  14. * distribution.
  15. * * Neither the name of Mahmood Ali. nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. package com.notnoop.apns;
  32. /**
  33. * A delegate that gets notified of the status of notification delivery to the
  34. * Apple Server.
  35. *
  36. * The delegate doesn't get notified when the notification actually arrives at
  37. * the phone.
  38. */
  39. public interface ApnsDelegate {
  40. /**
  41. * Called when message was successfully sent to the Apple servers
  42. *
  43. * @param message the notification that was sent
  44. * @param resent whether the notification was resent after an error
  45. */
  46. public void messageSent(ApnsNotification message, boolean resent);
  47. /**
  48. * Called when the delivery of the message failed for any reason
  49. *
  50. * If message is null, then your notification has been rejected by Apple but
  51. * it has been removed from the cache so it is not possible to identify
  52. * which notification caused the error. In this case subsequent
  53. * notifications may be lost. If this happens you should consider increasing
  54. * your cacheLength value to prevent data loss.
  55. *
  56. * @param message the notification that was attempted to be sent
  57. * @param e the cause and description of the failure
  58. */
  59. public void messageSendFailed(ApnsNotification message, Throwable e);
  60. /**
  61. * The connection was closed and/or an error packet was received while
  62. * monitoring was turned on.
  63. *
  64. * @param e the delivery error
  65. * @param messageIdentifier id of the message that failed
  66. */
  67. public void connectionClosed(DeliveryError e, int messageIdentifier);
  68. /**
  69. * The resend cache needed a bigger size (while resending messages)
  70. *
  71. * @param newCacheLength new size of the resend cache.
  72. */
  73. public void cacheLengthExceeded(int newCacheLength);
  74. /**
  75. * A number of notifications has been queued for resending due to a error-response
  76. * packet being received.
  77. *
  78. * @param resendCount the number of messages being queued for resend
  79. */
  80. public void notificationsResent(int resendCount);
  81. /**
  82. * A no operation delegate that does nothing!
  83. */
  84. public final static ApnsDelegate EMPTY = new ApnsDelegateAdapter();
  85. }