Terribly sorry - it seems that I got this one incorrect.
You CAN initiate a message through a UDP listener. You can use ogscript.getListenerById("ID_YOU_GAVE_THE_LISTENER"); to get the listener object and have access to:
listener.sendUDPAsBytes(HOST, PORT, BYTES_AS_STRING)
listener.sendUDPBytes(HOST, PORT, BYTE_ARRAY)
and
listener.sendUDPString(HOST, PORT, STRING)
Here is a relatively simple example panel that runs 2 UDP listeners:
One acts as a server and takes any string it is sent, reverses it, and sends it back to the port
The other acts as the 'client' and outputs any response from the server
The button requests the client listener object and sends the string "Hello World" to the server.
<abs contexttype="opengear" style="">
<meta>
<listener autostart="true" listenport="2345" maxlength="1024" udp="true">
<task tasktype="ogscript">if (event.isMessageEvent())
{
var myString = event.getBytesAsString() + "";
var response = "";
for (var i = myString.length - 1; i >= 0; i--)
{
response += myString.charAt(i);
}
this.writeString(response, false);
}</task>
</listener>
<listener autostart="true" id="listener-to-send-through" listenport="1234" maxlength="1024" udp="true">
<task tasktype="ogscript">if (event.isMessageEvent())
{
ogscript.debug("GOT RESPONSE: " + event.getBytesAsString());
}
</task>
</listener>
</meta>
<button buttontype="push" height="148" left="21" top="18" width="219">
<task tasktype="ogscript">var listener = ogscript.getListenerById("listener-to-send-through");
listener.sendUDPString("localhost", 2345, "Hello World");</task>
</button>
</abs>
#DashBoard