TsgcWSCircuitBreaker › Methods › RegisterConnection
Server-side hook that tracks a new connection (reserved for future per-IP metrics).
procedure RegisterConnection(const aIP: string);
| Name | Type | Description |
|---|---|---|
aIP | const string | Peer IP address of the newly accepted connection. |
Reserved hook currently implemented as a no-op when SGC_CIRCUITBREAKER is enabled — future releases will use it to track per-IP connection counts so the breaker can raise OnFailureRecorded / OnCallRejected at the IP granularity. Call it from the server's OnConnect handler after IsConnectionAllowed returns True, and pair every call with UnregisterConnection in OnDisconnect so the tracking stays balanced. Safe to call today — it guarantees forward compatibility with no observable behavior change.
procedure TForm1.WSServerConnect(Connection: TsgcWSConnection);
begin
if not sgcWSCircuitBreaker1.IsConnectionAllowed(Connection.PeerIP) then
begin
Connection.Disconnect;
Exit;
end;
sgcWSCircuitBreaker1.RegisterConnection(Connection.PeerIP);
end;
procedure TForm1.WSServerDisconnect(Connection: TsgcWSConnection);
begin
sgcWSCircuitBreaker1.UnregisterConnection(Connection.PeerIP);
end;