IdSystatServer.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.7 12/2/2004 4:23:58 PM JPMugaas
  18. Adjusted for changes in Core.
  19. Rev 1.6 10/26/2004 10:49:20 PM JPMugaas
  20. Updated ref.
  21. Rev 1.5 2004.02.03 5:44:30 PM czhower
  22. Name changes
  23. Rev 1.4 1/21/2004 4:04:04 PM JPMugaas
  24. InitComponent
  25. Rev 1.3 2/24/2003 10:29:50 PM JPMugaas
  26. Rev 1.2 1/17/2003 07:10:58 PM JPMugaas
  27. Now compiles under new framework.
  28. Rev 1.1 1/8/2003 05:53:54 PM JPMugaas
  29. Switched stuff to IdContext.
  30. Rev 1.0 11/13/2002 08:02:28 AM JPMugaas
  31. }
  32. unit IdSystatServer;
  33. {
  34. Indy Systat Client TIdSystatServer
  35. Copyright (C) 2002 Winshoes Working Group
  36. Original author J. Peter Mugaas
  37. 2002-August-13
  38. Based on RFC 866
  39. Note that this protocol is officially called Active User
  40. }
  41. interface
  42. {$i IdCompilerDefines.inc}
  43. uses
  44. Classes,
  45. IdAssignedNumbers,
  46. IdContext,
  47. IdCustomTCPServer;
  48. type
  49. TIdSystatEvent = procedure (AThread: TIdContext; AResults : TStrings) of object;
  50. Type
  51. TIdSystatServer = class(TIdCustomTCPServer)
  52. protected
  53. FOnSystat : TIdSystatEvent;
  54. //
  55. function DoExecute(AThread: TIdContext): boolean; override;
  56. public
  57. constructor Create(AOwner: TComponent); override;
  58. published
  59. property OnSystat : TIdSystatEvent read FOnSystat write FOnSystat;
  60. property DefaultPort default IdPORT_SYSTAT;
  61. end;
  62. {
  63. Note that no result parsing is done because RFC 866 does not specify a syntax for
  64. a user list.
  65. Quoted from RFC 866:
  66. There is no specific syntax for the user list. It is recommended
  67. that it be limited to the ASCII printing characters, space, carriage
  68. return, and line feed. Each user should be listed on a separate
  69. line.
  70. }
  71. implementation
  72. uses
  73. IdGlobal, SysUtils;
  74. { TIdSystatServer }
  75. constructor TIdSystatServer.Create(AOwner: TComponent);
  76. begin
  77. inherited Create(AOwner);
  78. DefaultPort := IdPORT_SYSTAT;
  79. end;
  80. function TIdSystatServer.DoExecute(AThread: TIdContext): boolean;
  81. var
  82. s : TStrings;
  83. begin
  84. Result := True;
  85. if Assigned(FOnSystat) then
  86. begin
  87. s := TStringList.Create;
  88. try
  89. FOnSystat(AThread,s);
  90. AThread.Connection.IOHandler.Write(s);
  91. finally
  92. s.Free;
  93. end;
  94. end;
  95. AThread.Connection.Disconnect;
  96. end;
  97. end.