From 46da402f7447afef9cf542cc04cc520ead0ee073 Mon Sep 17 00:00:00 2001 From: Peter Saxton Date: Tue, 8 Mar 2022 15:59:18 +0100 Subject: [PATCH] client_sub: notify when there are no notifications on a publication response --- client_sub.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client_sub.go b/client_sub.go index 460b87d9..e05f1ce8 100644 --- a/client_sub.go +++ b/client_sub.go @@ -265,6 +265,8 @@ func (c *Client) notifySubscriptionsOfError(ctx context.Context, subID uint32, e } } +var ErrNoNotifs = errors.New("no notifications in publish response") + func (c *Client) notifySubscription(ctx context.Context, sub *Subscription, notif *ua.NotificationMessage) { // todo(fs): response.Results contains the status codes of which messages were // todo(fs): were successfully removed from the transmission queue on the server. @@ -281,6 +283,14 @@ func (c *Client) notifySubscription(ctx context.Context, sub *Subscription, noti return } + if len(notif.NotificationData) == 0 { + sub.notify(ctx, &PublishNotificationData{ + SubscriptionID: sub.SubscriptionID, + Error: ErrNoNotifs, + }) + return + } + // Part 4, 7.21 NotificationMessage for _, data := range notif.NotificationData { // Part 4, 7.20 NotificationData parameters