Page 1 of 1

Subscribe to node internally in this server

Posted: 16 Jul 2021, 13:48
by YFR
Hello,
Having developed a server with .NET SDK, I would like to subscribe to node internally in this server (monitoring change to node value made by the client).
I can see a similar topics in the forum, but for the C++ SDK counterpart ("How do I read or subscribe for data internally in the server" + "Modify a Variable value when another one (or more) change it").

Could you indicate, in .NET C# context, which functions to use, or some sample code, to provide a point to start from, please ?
Thank you.
Yves

Re: Subscribe to node internally in this server

Posted: 23 Jul 2021, 12:51
by Support Team
the c# counterpart is the ServerInternalClient.

Code: Select all

                ServerInternalClient client = new ServerInternalClient(Server);
                InternalClientFastDataMonitoredItem item = new InternalClientFastDataMonitoredItem()
                {
                    NodeId = ObjectIds.Server,
                    AttributeId = Attributes.Value,
                    Callback = YourCallback
                };

                var list = new List<InternalClientFastDataMonitoredItem>();
                list.Add(item);
                var results = client.CreateDataMonitoredItems(Server.DefaultRequestContext, list);
The InternalClientFastDataMonitoredItem will deliver the changes immediately to the Callback, if need more options use the InternalClientFullDataMonitoredItem.