Search in sources :

Example 1 with Notification

use of org.openhab.ui.habot.notification.internal.webpush.Notification in project habot by ghys.

the class NotificationService method sendNotification.

/**
 * Sends a web push notification to a specified subscription
 *
 * @param subscription the subscription to send the notification to
 * @param payload the payload to push
 * @return the {@link Future} for the {@link Response} to the push server
 * @throws GeneralSecurityException
 */
public Future<Response> sendNotification(Subscription subscription, String payload) throws GeneralSecurityException {
    getPushService();
    Notification notification = new Notification(subscription, payload);
    try {
        return this.pushService.send(notification);
    } catch (IOException | JoseException | ExecutionException | InterruptedException e) {
        logger.error("Unable to send the notification to {}: {}", this.subscriptionProvider.keyToString(subscription.keys), e.toString());
        return null;
    }
}
Also used : JoseException(org.jose4j.lang.JoseException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Notification(org.openhab.ui.habot.notification.internal.webpush.Notification)

Aggregations

IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 JoseException (org.jose4j.lang.JoseException)1 Notification (org.openhab.ui.habot.notification.internal.webpush.Notification)1