Using a Global Listener

Global listener is used to process Tokens, for example, to get states of Driver Token, Feedback, System Token, Project Token and keep track of items states in a project. Having subscribed once, the listener works in the future when the is any change of the value of Feedback/Driver Token/System Token/Project Token.
Before you had to process tokens each tim ein different functions. Now it is written once and data always come in the required token. For example, having subscribed to, the start of requied tags, and they work each time wheh the value changes. Earlier it was necessaty to write them manually in required fields via GetVariable each time what they have to be called. A greate change is that now it's possible to keep track of item changes.


Here is a function that will display data from tokens with changed value in IR.Log
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(name, value)
{
IR.Log("Global listener is activated Активирован: " + name + "\tValue: " + value);
});

Then we are to subscribe to a token for the system to register its changes.
Examples:
IR.SubscribeTagChange("Drivers.AV & Custom Systems (TCP).Feedback"); Subscribe to driver feedback
IR.SubscribeTagChange("System.Time.Second"); Subscribe to the system token of displaying seconds.
IR.SubscribeTagChange("Drivers.AV & Custom Systems (TCP).Online");Subscribe to the driver token Online.
IR.SubscribeTagChange("Global.Log"); Subscribe to the project token.
IR.SubscribeTagChange("UI.Page 1.Item 1.Text"); Subscribe to the item changes

It's possible to unsubscribe from tokens this way:
IR.UnsubscribeTagChange("Global.Log");

When a global listener is used in Server projects, change addressing tags this way:

IR.SubscribeTagChange("Server.Tags.AV & Custom Systems (TCP).GlobalListener"); Subscribe to driver feedback.
IR.SubscribeTagChange("System.Time.Second"); Subscribe to the system token of displaying seconds (not available yet)
IR.SubscribeTagChange("Server.Tags.AV & Custom Systems (TCP).Online"); Subscribe to the driver token Online.
IR.SubscribeTagChange("Server.Tags.Loging"); Subscribe to the project token..

It's possible to unsubscribe from tokens this way::
IR.UnsubscribeTagChange("Server.Tags.Loging");

!GLOBAL LISTENER WORK ONLY WHEN VALUE CHANGES!

To study the topic deeper download the following projects:
Client part
Server part + client part on the basis of a server

This article was helpful for 6 people. Is this article helpful for you?