Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notify when there are no notifications on a publication response #565

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions client_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down