TsgcTURNClientEvents › OnTURNAllocate

OnTURNAllocate Event

Fires after a successful ALLOCATE response; exposes the relayed IP address and port assigned by the server.

Syntax

property OnTURNAllocate: TsgcTURNAllocateEvent;
// TsgcTURNAllocateEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aMessage: TsgcSTUN_Message; const aAllocation: TsgcTURN_ResponseAllocation) of object

Default Value

Remarks

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.

Example

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;

Back to Events