TsgcTURNServer › Events › OnTURNBeforeRelayIndication
Raised before the server relays a Send-Indication payload to a peer; set Accept to False to drop the packet.
property OnTURNBeforeRelayIndication: TsgcTURNBeforeRelayIndicationEvent;
// TsgcTURNBeforeRelayIndicationEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aPeerIP: string; aPeerPort: Word; const aBytes: TBytes; var Accept: Boolean) of object
—
Fired on the relay hot-path, once per Send-Indication (RFC 5766 section 10): the client has sent a SEND indication carrying application data that must be forwarded to a peer for which a permission already exists. aPeerIP/aPeerPort identify the target peer (taken from XOR-PEER-ADDRESS) and aBytes contains the payload that is about to be relayed on the Allocation's relay socket. Use the event to inspect or capture the relayed traffic (for example to sniff audio/video packets sent through the TURN server) or to implement per-peer rate limiting. Set Accept := False to silently drop the datagram; no error is sent to the sending client. This event fires on the relay path and runs synchronously unless NotifyEvents redirects it — consider neNoSync under heavy load to avoid back-pressure on the listener. aBytes is a read-only view; do not modify its contents.
procedure TForm1.OnTURNBeforeRelayIndication(Sender: TObject;
const aSocket: TsgcSocketConnection; const aPeerIP: string; aPeerPort: Word;
const aBytes: TBytes; var Accept: Boolean);
begin
vBytesRelayed := vBytesRelayed + Length(aBytes);
Accept := True;
end;