IdSystatServer.pas 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. procedure InitComponent; override;
  57. published
  58. property OnSystat : TIdSystatEvent read FOnSystat write FOnSystat;
  59. property DefaultPort default IdPORT_SYSTAT;
  60. end;
  61. {
  62. Note that no result parsing is done because RFC 866 does not specify a syntax for
  63. a user list.
  64. Quoted from RFC 866:
  65. There is no specific syntax for the user list. It is recommended
  66. that it be limited to the ASCII printing characters, space, carriage
  67. return, and line feed. Each user should be listed on a separate
  68. line.
  69. }
  70. implementation
  71. uses
  72. IdGlobal, SysUtils;
  73. { TIdSystatServer }
  74. procedure TIdSystatServer.InitComponent;
  75. begin
  76. inherited;
  77. DefaultPort := IdPORT_SYSTAT;
  78. end;
  79. function TIdSystatServer.DoExecute(AThread: TIdContext): boolean;
  80. var
  81. s : TStrings;
  82. begin
  83. Result := True;
  84. if Assigned(FOnSystat) then
  85. begin
  86. s := TStringList.Create;
  87. try
  88. FOnSystat(AThread,s);
  89. AThread.Connection.IOHandler.Write(s);
  90. finally
  91. FreeAndNil(s);
  92. end;
  93. end;
  94. AThread.Connection.Disconnect;
  95. end;
  96. end.