Atozed Forums
[NNTP server]How to response with list of groups? - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Indy (https://www.atozed.com/forums/forum-8.html)
+--- Forum: Indy General Discussion (https://www.atozed.com/forums/forum-9.html)
+--- Thread: [NNTP server]How to response with list of groups? (/thread-1473.html)



[NNTP server]How to response with list of groups? - AndrzejB - 01-06-2020

If cliient ask about list of group - is called procedure TForm1.IdNNTPServer1ListGroups(AContext: TIdContext);i
Im ust modify AContext or send multiple times to client items of list which can be large?


RE: [NNTP server]How to response with list of groups? - rlebeau - 01-07-2020

The OnListGroups event is fired in response to a LIST command with no parameters. You need to write out the individual groups in the format used by the LIST ACTIVE command, eg:

Code:
procedure TForm1.IdNNTPServer1ListGroups(AContext: TIdContext);
begin
  with AContext.Connection.IOHandler do
  begin
    WriteLnRFC('group1 <high> <low> <status>');
    WriteLnRFC('group2 <high> <low> <status>');
    WriteLnRFC('group3 <high> <low> <status>');
    // and so on ...
  end;
end;

Or:

Code:
procedure TForm1.IdNNTPServer1ListGroups(AContext: TIdContext);
var
  List: TStringList;
begin
  List := TStringList.Create;
  try
    List.Add('group1 <high> <low> <status>');
    List.Add('group2 <high> <low> <status>');
    List.Add('group3 <high> <low> <status>');
    // and so on ...

    // using AWriteTerminator=False because TIdNNTPServer sends a list
    // terminator after the OnListGroups event handler exits...
    AContext.Connection.IOHandler.WriteRFCStrings(List, False);
  finally
    List.Free;
  end;
end;



RE: [NNTP server]How to response with list of groups? - AndrzejB - 01-07-2020

I must add dot at end or it is automatic?


RE: [NNTP server]How to response with list of groups? - rlebeau - 01-07-2020

It is automatic. I stated as much in my previous reply:

Quote:TIdNNTPServer sends a list terminator after the OnListGroups event handler exits