Skip to content

Trigger actions

A client can attach actions to the inputs of a faceoff: an OSC message to send when an input wins and another when it loses. TriggerGate sends them itself, the moment each place is decided, so the result reaches the sound system, the graphics or a lighting desk that listens for OSC without a round trip through the client. This page explains when actions run, how OSC is addressed and sent, how to set the defaults and test them from the web page, and what lighting actions do today.

Where actions are available

Trigger actions are available on the Windows service (Advantech cards and X-keys), the Advantech UNO, and the ESP32. The ESP32 supports OSC actions, including scheduled faceoffs, but does not support lighting output. Its OSC sender has the limits below.

The web page does not attach actions to the faceoffs it starts; a show-control application does, through the .NET client library or the hub API. The web page's settings set the OSC defaults and send a test message.

When actions run

Actions travel with the request that starts a faceoff (ResetFaceoff), keyed by input number. Each input can have a set of winner actions and a set of loser actions; each set can hold one OSC action and one lighting action.

Event What runs
An input's entry is placed 1st That input's winner actions
An input's entry is placed second or later That input's loser actions
A tie Each entry runs the actions for the place the random order gives it; in a tie for first place, only the entry placed first runs its winner actions
ResetFaceoff with no inputs (ending the faceoff) Every action supplied with that request, at once, in input order, winner before loser
A new ResetFaceoff with inputs Replaces the faceoff and its actions
A pre-faceoff, a lockout, a press while locked out Nothing

Actions run once per entry, as each place is decided: at once for a polled entry, and when its group is decided for an interrupt entry (2D after the group's last entry, 300 µs by default on .NET platforms). Ending a faceoff with actions is how a client sets the "faceoff over" state, for example every podium light back to idle, in one call. Scheduled ESP32 faceoffs can also carry actions.

A request whose actions do not validate is refused whole, and the current faceoff is left as it was. Actions are refused when:

  • they name an input that is not taking part in the faceoff;
  • an OSC packet is empty, malformed or larger than one UDP datagram (1472 bytes on ESP32);
  • an OSC destination has no port, or the source subnet matches none of the server's network interfaces;
  • a lighting action has a negative start index or no data.

On .NET platforms, everything that can fail (checking the packet, finding the network interface, opening the socket) happens when the request arrives, not when a button is pressed. At the moment of an entry the service queues an already prepared message, and a background thread sends it. The ESP32 instead queues OSC work for a low-priority sender, which opens and sends the UDP socket after the decision. A faceoff's prepared OSC payload is limited to 8192 bytes in total. The outgoing queue separately holds at most 32 actions and 8192 payload bytes. A full queue refuses a direct RunOsc; a faceoff action that cannot be queued is logged and dropped without changing the faceoff timing result.

OSC actions

An OSC action carries a complete OSC packet, a message or a bundle, exactly as it should appear on the network. TriggerGate checks its framing and forwards the bytes unchanged; type tags it does not know are accepted. You can build the packet with the GameshowPro.Osc package or any other OSC library.

Each action can also name:

  • a destination, an address and port, often a multicast group;
  • a source subnet, which chooses the network interface to send from: the first interface with an address inside that subnet. This matters for multicast on a machine with several network adapters, where the operating system would otherwise pick the interface.

An action that leaves either out uses the device's defaults, set in the web page's settings. If those are blank too, the destination is 239.255.0.1:9000, a multicast group that a listener on the same network can see, and the operating system chooses the interface. Multicast is sent with a time to live of 1, so it never leaves the local network.

OSC defaults and the test message

The web page's Settings dialog has a section OSC playback defaults on the Windows service, UNO, and ESP32:

Field What to enter
Destination (address:port) Where OSC actions that name no destination are sent, for example 239.255.0.1:9000. Blank uses the built-in default.
Source subnet (address/prefix) The subnet whose network interface sends OSC, for example 192.168.1.0/24. The list offers the server's own subnets, and you can type another. Blank lets the operating system choose.
Test OSC address OSC address used by Send test OSC. It must start with /, contain no control characters, and be at most 256 UTF-8 bytes. Blank uses /triggergate/test.

Send test OSC sends the configured test address with no arguments, using the current unsaved field values, and shows whether the server sent it. Save stores the OSC defaults and test address for this device only; each device has its own. The test address affects this button only; it does not change faceoff action addresses or packets supplied to RunOsc.

The WPF settings view that comes with the .NET client library edits the same defaults and test address. Leaving the test-address field applies the edit; the Send test OSC button uses that address. ESP32 OSC uses IPv4 Ethernet; it reports its available source subnets and saves the defaults in flash.

Lighting actions

A lighting action, LightingAction(StartIndex, Data), overwrites part of a lighting universe: Data replaces the bytes starting at StartIndex. On .NET platforms TriggerGate accepts and checks lighting actions and writes each one to the service log as a warning, with its length and start index; it does not drive lighting output. The ESP32 does not support lighting actions and refuses requests that include them.

Running an action on demand

Two hub commands run a single action at once, through the same path a faceoff edge uses, so a client can check its settings without a faceoff:

  • RunOsc sends one OSC action. The web page's Send test OSC button uses it.
  • RunAction applies one lighting action, which is logged as described above.

Example

With the .NET client library, a faceoff between inputs 0 and 1 that sends /podium/<input>/win or /podium/<input>/lose, to the device's default destination:

using GameshowPro.Osc;
using GameshowPro.TriggerGate.Model;

static TriggerActions Osc(string address, int input)
    => new(new OscAction(new OscMessage(address, input).ToArray()), null);

Dictionary<int, TriggerActionsByResult> actions = new()
{
    [0] = new(Osc("/podium/0/win", 0), Osc("/podium/0/lose", 0)),
    [1] = new(Osc("/podium/1/win", 1), Osc("/podium/1/lose", 1)),
};

TriggerDefinition[] inputs = [new(0, true), new(1, true)]; // input number, press is a rising edge
await client.ResetFaceoff(inputs, actions);

To watch what the service sends, the tgtest osc-listen command joins the multicast group and prints every datagram it receives; see The tgtest tool.

v2.0.62