TsgcSTUNServer › Events › OnSTUNRequestSuccess
Raised before the server sends a successful Binding 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 Binding Request successfully and built the response carrying the client's public (mapped) address, but before the datagram is sent. aRequest exposes the original STUN message (transaction id, attributes, source endpoint) and aResponse exposes the Binding Response that is about to be transmitted; both may be inspected for logging or auditing. Set Accept := False to discard the response silently, for example to implement custom rate limiting or per-client black-listing. 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('Binding OK from ' + aSocket.PeerIP + ':' + IntToStr(aSocket.PeerPort));
Accept := True;
end;