0
Beantwoord

How to listen clients with iRidium server.

TuomoHautala 7 jaar geleden in Applications / i3 Pro bijgewerkt door Aleksandr Romanov (CTO) 7 jaar geleden 5

Another odd question. I have set up iRidium server and it is easy create drivers (clients) that will connect to equipment. But now i have client that will connect to iRidium server and send commands / requests to server. I have no idea how can I listen and log those request / commands from script. So how is that done? :)Image 19049

+1

[code]

   IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function (name, value)
   {
      IR.Log(name + ">" + value);
      
      switch (name){
         case ("Server.Channels.getTechnicalData"):
            //Insert code
            break;

         case ("Server.Channels.getAreaData"):

            //Insert code

            break;

         case ("Server.Channels.getAreaNumbersAndNames"):

            //Insert code

            break;

      }
   });
   IR.SubscribeTagChange("Server.Channels.getTechnicalData");

   IR.SubscribeTagChange("Server.Channels.getAreaData");

   IR.SubscribeTagChange("Server.Channels.getAreaNumbersAndNames");

[/code]


Remeber, You can have _only one_ "EVENT_GLOBAL_TAG_CHANGE" on you project.

Also, you can use the parameter "Script Modifier" on Channels. With this parameter you can call one function on JS.

So, for example, if you write this function

function virtual_to_virtual (in_Type, in_Name, in_Value) 
{
   var namepart = in_Name.split(".");  
   IR.SetVariable("Server.Tags."+ in_Name, in_Value);
   return in_Value;
}

and set "Script Modifier" parameter of channel named as getTechnicalData for run function "virtual_to_virtual" then you can copy the value of channel on tag with same name.

So for example if i have nodejs client that will connect to server and send requests / commands to iRidium server, is there iRidium server RECEIVE script EVENT so i can log requests / commands and use the in my script?