TsgcTURNClient › Events › OnTURNAllocate
Fires after a successful ALLOCATE response; exposes the relayed IP address and port assigned by the server.
property OnTURNAllocate: TsgcTURNAllocateEvent;
// TsgcTURNAllocateEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aMessage: TsgcSTUN_Message; const aAllocation: TsgcTURN_ResponseAllocation) of object
—
Fires when the TURN server answers an Allocate request with a success response. Read aAllocation.RelayedIP, aAllocation.RelayedPort, aAllocation.Lifetime and the mapped address to publish the relay candidate to peers (for example via the signalling channel used by WebRTC). The same information is cached in the client's Allocation property.
procedure TForm1.oTURNTURNAllocate(Sender: TObject;
const aSocket: TsgcSocketConnection; const aMessage: TsgcSTUN_Message;
const aAllocation: TsgcTURN_ResponseAllocation);
begin
DoLog('Relayed IP: ' + aAllocation.RelayedIP +
'. Relayed Port: ' + IntToStr(aAllocation.RelayedPort));
end;