TsgcTURNServerEvents › OnTURNBeforeRelayChannelData

OnTURNBeforeRelayChannelData Event

Raised before the server relays a ChannelData payload to a peer; set Accept to False to drop the packet.

Syntax

property OnTURNBeforeRelayChannelData: TsgcTURNBeforeRelayChannelDataEvent;
// TsgcTURNBeforeRelayChannelDataEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; aRelayType: TsgcTURNRelayChannelDataType; const aPeerIP: string; aPeerPort: Word; const aChannelData: TsgcTURNChannelData; var Accept: Boolean) of object

Default Value

Remarks

Fired on the relay hot-path for ChannelData traffic (RFC 5766 section 11): the lightweight 4-byte framing that TURN uses instead of Send/Data indications once a channel has been bound with CHANNEL-BIND. aRelayType indicates the direction of the relay (client-to-peer vs peer-to-client) and aPeerIP/aPeerPort identify the remote endpoint. aChannelData exposes the channel number and the payload bytes that are about to be forwarded. Use the event to inspect the media stream (audio/video captured through the TURN server) or to enforce per-channel rate limits. Set Accept := False to silently drop the datagram — no error is sent to either party. This event fires for every relayed ChannelData packet, so keep the handler lean; runs synchronously unless NotifyEvents redirects it. Use neNoSync under sustained load to avoid back-pressure on the listener.

Example

procedure TForm1.OnTURNBeforeRelayChannelData(Sender: TObject;
  const aSocket: TsgcSocketConnection; aRelayType: TsgcTURNRelayChannelDataType;
  const aPeerIP: string; aPeerPort: Word; const aChannelData: TsgcTURNChannelData;
  var Accept: Boolean);
begin
  Accept := True;
end;

Back to Events