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
How to check whether events are subscribed from the client?
Moderator: uasdkcpp
-
- Jr. Member
- Posts: 1
- Joined: 25 May 2018, 10:52
- Support Team
- Hero Member
- Posts: 3073
- Joined: 18 Mar 2011, 15:09
Re: How to check whether events are subscribed from the clie
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.
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
Unified Automation Support Team
-
- Jr. Member
- Posts: 4
- Joined: 07 Nov 2018, 09:41
Re: How to check whether events are subscribed from the clie
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?
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?
-
- Jr. Member
- Posts: 4
- Joined: 07 Nov 2018, 09:41
Re: How to check whether events are subscribed from the clie
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.
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.