Package com.iizix.push
Class PushServer
java.lang.Object
com.iizix.push.PushServer
Push server for VAPID, Firebase and APNS messages.
- Author:
- Christopher Mindus
- Field SummaryFieldsModifier and TypeFieldDescription- static final intDefault Time-to-Live for Notifications in milliseconds: 24 days, extremely long time!
- Constructor SummaryConstructorsConstructorDescription- PushServer- (ExecutorService executorService, String vapidPublicKey, String vapidPrivateKey, String gcmApiKey, String subject) Constructs the push server.
- Method SummaryModifier and TypeMethodDescription- createNotification- (IPushSubscription subscription, String payloadMessage, int ttl, PushUrgency urgency, String topic) Constructs a new notification instance for use with browsers and non-Apple devices.- createSubscription- (String endPoint, String p256dh, String auth) Gets the subscription for a client used to later send a push notification.- void- push- (com.iizix.push.PushNotification notification) Adds a push notification to be sent to the client.
- Field Details- DEFAULT_TTLpublic static final int DEFAULT_TTLDefault Time-to-Live for Notifications in milliseconds: 24 days, extremely long time!- See Also:
 
 
- Constructor Details- PushServerpublic PushServer- (ExecutorService executorService, String vapidPublicKey, String vapidPrivateKey, String gcmApiKey, String subject) throws GeneralSecurityException Constructs the push server.- Parameters:
- executorService- The executor service handling multi-threading depending on the CPU config and queued requests.
- vapidPublicKey- The VAPIC public key.
- vapidPrivateKey- The VAPIC private key.
- gcmApiKey- Google Cloud Messaging API key, or- null for none.
- subject- The subject.
- Throws:
- NullPointerException- If- executorService,- vapidPublicKey,- vapidPrivateKeyor- subjectis- null.
- GeneralSecurityException- General security exception in case of errors.
 
 
- Method Details- createNotificationpublic IPushNotification createNotification- (IPushSubscription subscription, String payloadMessage, int ttl, PushUrgency urgency, String topic) Constructs a new notification instance for use with browsers and non-Apple devices.- Parameters:
- subscription- The subscription.
- payloadMessage- The payload message as plain text.
- ttl- The Time-to-Live in milliseconds of the message, zero or less for default 28 days = (2_419_200_000 milliseconds).
- urgency- The urgency of the notification.
- topic- The topic of the notification.
- Returns:
- A new notification instance.
- Throws:
- NullPointerException- If- subscription,- payloadMessageor- urgencyis- null.
 
- createSubscriptionGets the subscription for a client used to later send a push notification. The subscription can be stored in the IClientSessionGyro as it doesn't change for the client session.- Parameters:
- endPoint- The end point URL String.
- p256dh- The key encoded as a Base64 String.
- auth- The authentication encoded as a Base64 String.
- Returns:
- The subscription for the client.
- Throws:
- NullPointerException- If the- endPointis- null.
- IllegalArgumentException- If- p256dhor- authis not in valid Base64 scheme or invalid- p256dhkey encoding.
 
- pushpublic void push- (com.iizix.push.PushNotification notification) Adds a push notification to be sent to the client. The notification will be done by the executor service as soon as possible.- Parameters:
- notification- The notification to be sent.