TsgcWebSocketFirewallMethods › LoadBansFromStream

LoadBansFromStream Method

Reads ban records from any TStream (memory, network, resource) in the same format produced by SaveBansToStream.

Syntax

procedure LoadBansFromStream(aStream: TStream);

Parameters

NameTypeDescription
aStreamTStreamReadable stream positioned at the start of a ban set previously produced by SaveBansToStream.

Remarks

Use the stream overload when ban persistence lives outside the filesystem — for example, a database BLOB, an encrypted archive, a cluster coordination service, or a configuration message received over the network. Expired records are discarded and the new entries are merged with any existing bans. Pair with ClearBans if you want a clean replacement instead of a merge.

Example

var
  oStream: TMemoryStream;
begin
  oStream := TMemoryStream.Create;
  try
    oStream.LoadFromFile('bans.dat');
    oStream.Position := 0;
    sgcWebSocketFirewall1.LoadBansFromStream(oStream);
  finally
    oStream.Free;
  end;
end;

Back to Methods