Ogni volta che un server invia un messaggio al client, come risposta a un binding di richiesta, il messaggio STUN contiene un elenco di attributi con informazioni sulla risposta.
È possibile accedere a questi attributi utilizzando la classe TsgcSTUN_Message e la sua proprietà Attributes, che contiene un elenco di oggetti TsgcSTUN_Attribute con informazioni utili.
procedure OnSTUNResponseSuccess(Sender: TObject; const aSocket: TsgcSocketConnection;
const aMessage: TsgcSTUN_Message; const aBinding: TsgcSTUN_ResponseBinding);
var
i: Integer;
begin
DoLog('#binding: ' + aBinding.RemoteIP + ':' + IntToStr(aBinding.RemotePort));
for i := 0 to aMessage.Attributes.Count - 1 do
begin
case TsgcSTUN_Attribute(aMessage.Attributes.Items[i]).AttributeType of
stmaFingerprint:
DoLog('#fingerprint: ' + IntToStr(TsgcSTUN_Attribute_FINGERPRINT
(aMessage.Attributes.Items[i]).Fingerprint));
stmaSoftware:
DoLog('#software: ' + TsgcSTUN_Attribute_SOFTWARE
(aMessage.Attributes.Items[i]).Software);
stmaResponse_Origin:
DoLog('#response_origin: ' + TsgcSTUN_Attribute_RESPONSE_ORIGIN
(aMessage.Attributes.Items[i]).Address + ':' +
IntToStr(TsgcSTUN_Attribute_RESPONSE_ORIGIN(aMessage.Attributes.Items
[i]).Port));
stmaOther_Address:
DoLog('#other_address: ' + TsgcSTUN_Attribute_OTHER_ADDRESS
(aMessage.Attributes.Items[i]).Address + ':' +
IntToStr(TsgcSTUN_Attribute_OTHER_ADDRESS(aMessage.Attributes.Items
[i]).Port));
stmaSource_Address:
DoLog('#source_address: ' + TsgcSTUN_Attribute_SOURCE_ADDRESS
(aMessage.Attributes.Items[i]).Address + ':' +
IntToStr(TsgcSTUN_Attribute_SOURCE_ADDRESS(aMessage.Attributes.Items
[i]).Port));
stmaChanged_Address:
DoLog('#changed_address: ' + TsgcSTUN_Attribute_CHANGED_ADDRESS
(aMessage.Attributes.Items[i]).Address + ':' +
IntToStr(TsgcSTUN_Attribute_CHANGED_ADDRESS(aMessage.Attributes.Items
[i]).Port));
end;
end;
end;