TsgcWebSocketFirewallMethods › SaveBansToStream

SaveBansToStream Method

Serializes the active ban list into any writable TStream, useful for persistence backends that are not file-based (databases, network sync, encrypted archives).

Syntax

procedure SaveBansToStream(aStream: TStream);

Parameters

NameTypeDescription
aStreamTStreamWritable destination stream; data is appended at the current Position and Position is advanced past the written block.

Remarks

The produced layout is identical to SaveBansToFile and can therefore be round-tripped through LoadBansFromStream. Only active bans are written; expired entries are filtered out at serialization time. Call Seek(0, soBeginning) on the stream before reading it back.

Example

var
  oStream: TMemoryStream;
begin
  oStream := TMemoryStream.Create;
  try
    sgcWebSocketFirewall1.SaveBansToStream(oStream);
    oStream.SaveToFile('bans.dat');
  finally
    oStream.Free;
  end;
end;

Back to Methods