IdDayTimeUDPServer.pas 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.4 2004.02.03 5:45:04 PM czhower
  18. Name changes
  19. Rev 1.3 1/21/2004 2:12:44 PM JPMugaas
  20. InitComponent
  21. Rev 1.2 10/24/2003 02:54:52 PM JPMugaas
  22. These should now work with the new code.
  23. Rev 1.1 2003.10.24 10:38:24 AM czhower
  24. UDP Server todos
  25. Rev 1.0 11/14/2002 02:17:18 PM JPMugaas
  26. }
  27. unit IdDayTimeUDPServer;
  28. interface
  29. {$i IdCompilerDefines.inc}
  30. uses
  31. {$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
  32. Classes,
  33. {$ENDIF}
  34. IdAssignedNumbers, IdGlobal, IdSocketHandle, IdUDPServer;
  35. type
  36. TIdDayTimeUDPServer = class(TIdUDPServer)
  37. protected
  38. FTimeZone : String;
  39. procedure DoUDPRead(AThread: TIdUDPListenerThread; const AData: TIdBytes; ABinding: TIdSocketHandle); override;
  40. procedure InitComponent; override;
  41. {$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
  42. public
  43. constructor Create(AOwner: TComponent); reintroduce; overload;
  44. {$ENDIF}
  45. published
  46. property TimeZone: String read FTimeZone write FTimeZone;
  47. property DefaultPort default IdPORT_DAYTIME;
  48. end;
  49. implementation
  50. uses
  51. SysUtils;
  52. { TIdDayTimeUDPServer }
  53. {$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
  54. constructor TIdDayTimeUDPServer.Create(AOwner: TComponent);
  55. begin
  56. inherited Create(AOwner);
  57. end;
  58. {$ENDIF}
  59. procedure TIdDayTimeUDPServer.InitComponent;
  60. begin
  61. inherited InitComponent;
  62. DefaultPort := IdPORT_DAYTIME;
  63. FTimeZone := 'EST'; {Do not Localize}
  64. end;
  65. procedure TIdDayTimeUDPServer.DoUDPRead(AThread: TIdUDPListenerThread;
  66. const AData: TIdBytes; ABinding: TIdSocketHandle);
  67. var
  68. s : String;
  69. begin
  70. inherited DoUDPRead(AThread, AData, ABinding);
  71. s := FormatDateTime('dddd, mmmm dd, yyyy hh:nn:ss', Now) + ' -' + FTimeZone; {Do not Localize}
  72. ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, ToBytes(s), ABinding.IPVersion);
  73. end;
  74. end.