TsgcTURNServer › Events › OnTURNDeleteAllocation
Raised after an Allocation has been removed, either by client refresh-to-zero or because its lifetime expired.
property OnTURNDeleteAllocation: TsgcTURNAllocationEvent;
// TsgcTURNAllocationEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const Allocation: TsgcTURNAllocationItem) of object
—
Fired once per Allocation teardown: when the client issues a REFRESH with lifetime = 0, when the allocation lifetime expires on the server's internal timer, or when the server itself is deactivated (Active := False). Allocation still exposes the final snapshot of Username, RelayIP/RelayPort, Permissions, Channels and the last Expiry — useful to emit accounting records, close dashboards or release per-user resources. aSocket may be nil when the deletion is driven by the expiry timer rather than by a client request. The Allocation instance is freed by the server immediately after the handler returns; do not retain the reference. Runs on the listener/timer thread unless NotifyEvents redirects it.
procedure TForm1.OnTURNDeleteAllocation(Sender: TObject;
const aSocket: TsgcSocketConnection; const Allocation: TsgcTURNAllocationItem);
begin
Memo1.Lines.Add(Format('Allocation deleted: user=%s relay=%s:%d',
[Allocation.Username, Allocation.RelayIP, Allocation.RelayPort]));
end;