IdQotdServer.pas 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.5 12/2/2004 4:23:58 PM JPMugaas
  18. Adjusted for changes in Core.
  19. Rev 1.4 1/21/2004 3:27:14 PM JPMugaas
  20. InitComponent
  21. Rev 1.3 2/24/2003 09:29:30 PM JPMugaas
  22. Rev 1.2 1/17/2003 07:10:48 PM JPMugaas
  23. Now compiles under new framework.
  24. Rev 1.1 1/8/2003 05:53:46 PM JPMugaas
  25. Switched stuff to IdContext.
  26. Rev 1.0 11/13/2002 07:58:40 AM JPMugaas
  27. 2000-May-15 J. Peter Mugaas
  28. -renamed events to have Id prefix
  29. 2000-Apr-22 J Peter Mugaas
  30. Ported to Indy
  31. 2000-Jan-13 MTL
  32. Moved to new Palette Scheme (Winshoes Servers)
  33. 1999-May-13
  34. Final Version
  35. }
  36. unit IdQotdServer;
  37. interface
  38. {$i IdCompilerDefines.inc}
  39. {
  40. Original Author: Ozz Nixon
  41. (RFC 865) [less than 512 characters total, multiple lines OK!]
  42. }
  43. uses
  44. IdAssignedNumbers,
  45. IdContext,
  46. IdCustomTCPServer;
  47. Type
  48. TIdQOTDGetEvent = procedure(AContext: TIdContext; var AQuote: String) of object;
  49. TIdQOTDServer = class(TIdCustomTCPServer)
  50. protected
  51. FOnCommandQOTD : TIdQOTDGetEvent;
  52. //
  53. function DoExecute(AContext: TIdContext): Boolean; override;
  54. procedure InitComponent; override;
  55. published
  56. property OnCommandQOTD : TIdQOTDGetEvent read fOnCommandQOTD write fOnCommandQOTD;
  57. property DefaultPort default IdPORT_QOTD;
  58. end;
  59. implementation
  60. procedure TIdQOTDServer.InitComponent;
  61. begin
  62. inherited InitComponent;
  63. DefaultPort := IdPORT_QOTD;
  64. end;
  65. function TIdQOTDServer.DoExecute(AContext:TIdContext) : Boolean;
  66. var
  67. LQuote : String;
  68. begin
  69. Result := True;
  70. if Assigned(OnCommandQOTD) then
  71. begin
  72. OnCommandQOTD(AContext, LQuote);
  73. AContext.Connection.IOHandler.Write(LQuote);
  74. end;
  75. AContext.Connection.Disconnect;
  76. end;
  77. end.