TsgcTURNServer事件 › OnTURNCreateAllocation

OnTURNCreateAllocation 事件

当成功为客户端创建新的 Allocation 后触发。

语法

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

默认值

备注

每次成功分配后触发一次,时机紧接在分配被添加到服务器内部表且 AllocateResponse 已发送给客户端之后。Allocation 暴露完整上下文:LocalIP/LocalPort(服务器端监听端点)、ReflexiveIP/ReflexivePort(客户端映射地址)、RelayIP/RelayPort(通过 XOR-RELAYED-ADDRESS 通告给客户端的中继传输地址)、Username/RealmLifetime/Expiry 以及 Permissions/Channels 子集合。使用它更新运营仪表板、计费或每用户配额。Allocation 实例归服务器所有,请勿释放;它将在分配到期时再次传递给 OnTURNDeleteAllocation。除非 NotifyEvents 重定向,否则在监听器线程上运行。

示例

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;

返回事件