TsgcTURNServer › Events › OnSTUNRequestSuccess
Raised before the server sends a successful STUN/TURN response so the handler can inspect or veto the reply.
property OnSTUNRequestSuccess: TsgcSTUNRequestSuccessEvent;
// TsgcSTUNRequestSuccessEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aRequest, aResponse: TsgcSTUN_Message; var Accept: Boolean) of object
—
Fired after the server has processed a request successfully and built the response, but before the datagram is sent. Triggers on every STUN Binding Response and on every successful TURN method reply (AllocateResponse, RefreshResponse, CreatePermissionResponse, ChannelBindResponse). aRequest exposes the original STUN/TURN message (transaction id, attributes, source endpoint) and aResponse exposes the response about to be transmitted; both may be inspected for logging or auditing. Set Accept := False to discard the response silently — use sparingly on TURN methods because the client will retransmit and a dropped AllocateResponse can strand a server-side Allocation. The handler runs on the listener thread unless NotifyEvents redirects it.
procedure TForm1.OnSTUNRequestSuccess(Sender: TObject;
const aSocket: TsgcSocketConnection; const aRequest, aResponse: TsgcSTUN_Message;
var Accept: Boolean);
begin
Memo1.Lines.Add('TURN OK from ' + aSocket.PeerIP + ':' + IntToStr(aSocket.PeerPort));
Accept := True;
end;