How to check whether events are subscribed from the client?

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
AnandPS
Jr. Member
Jr. Member
Posts: 1
Joined: 25 May 2018, 10:52

How to check whether events are subscribed from the client?

Post by AnandPS »

I would like to know how to check (in the Server code) events are subscribed (event notifier object added to the client Event view) from the client, so that based on the event subscription the data collection from PLC/Controller will happen and the OPC events will be created and fired to the clients.

Regards,
Anand

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: How to check whether events are subscribed from the clie

Post by Support Team »

Hello Anand,

there is not an out-of-box way to do that. You need to implement your own EventManager to handle this.
E.g. you could subclass EventManagerUaNode and override some of the methods on the EventManager interface to track the number of MonitoredItems that are possible consumers of Events that your namespace produces.
Candidates are beginStartMonitoring, beginModifyMonitoring, beginStopMonitoring.
Best regards
Unified Automation Support Team

Syles
Jr. Member
Jr. Member
Posts: 4
Joined: 07 Nov 2018, 09:41

Re: How to check whether events are subscribed from the clie

Post by Syles »

Can you provide some sample code or snippets?
Do i have to register the subclassed EventManager? If so, where do i do that?
Let UaNodeId("notifierNode", 2) be a node, by which an event should be fired to all connected clients if a new client subscribes to this node. That would happen in beginStartMonitoring, right?

Syles
Jr. Member
Jr. Member
Posts: 4
Joined: 07 Nov 2018, 09:41

Re: How to check whether events are subscribed from the clie

Post by Syles »

Ah ok, i found a (simple) way to do that..

In my NodeManager, i'm subclassing from NodeManagerBase, which subclasses from EventManagerUaNode (if Event Subscription Server Facet is supported) which then subclasses from EventManagerBase.

So i can simply override EventManagerBase::beginStartMonitoring(OpcUa_Handle, OpcUa_UInt32, OpcUa_UInt32, EventCallback*, const EventMonitoringContextCreate&) and can check in there, which node is to be subscribed from a client and react to it.

Post Reply