TsgcTURNServerEventos › OnTURNCreateAllocation

OnTURNCreateAllocation Evento

Gerado depois que uma nova Allocation foi criada com sucesso para um cliente.

Sintaxe

property OnTURNCreateAllocation: TsgcTURNAllocationEvent;
// TsgcTURNAllocationEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const Allocation: TsgcTURNAllocationItem) of object

Valor Padrão

Observações

Disparado uma vez por ALLOCATE bem-sucedido, logo após a Allocation ter sido adicionada à tabela interna do servidor e a AllocateResponse ter sido despachada ao cliente. Allocation expõe o contexto completo: LocalIP/LocalPort (endpoint de escuta do lado do servidor), ReflexiveIP/ReflexivePort (endereço mapeado do cliente), RelayIP/RelayPort (o endereço de transporte de relay anunciado ao cliente via XOR-RELAYED-ADDRESS), Username/Realm, Lifetime / Expiry e as subcoleções Permissions / Channels. Utilize-o para atualizar dashboards operacionais, contabilidade ou cotas por usuário. A instância de Allocation é de propriedade do servidor — não a libere; ela é passada novamente para OnTURNDeleteAllocation quando a alocação expira. É executado na thread do listener, a menos que NotifyEvents o redirecione.

Exemplo

procedure TForm1.OnTURNCreateAllocation(Sender: TObject;
  const aSocket: TsgcSocketConnection; const Allocation: TsgcTURNAllocationItem);
begin
  Memo1.Lines.Add(Format('Allocation created: user=%s relay=%s:%d lifetime=%d',
    [Allocation.Username, Allocation.RelayIP, Allocation.RelayPort,
     Allocation.Lifetime]));
end;

Voltar para Eventos