ntfy-for-delphi icon indicating copy to clipboard operation
ntfy-for-delphi copied to clipboard

New unit for NetHTTP

Open p-samuel opened this issue 1 year ago • 3 comments

  • A new unit was created packing the NetHTTP routines. This unit will be used as an alternative to the already existing Indy unit and will be instanciated in the API factory unit. The developer will be able to choose which library he wants to utilize to make the ntfy HTTP comunication by a compiler directive called NTFY_HTTP_INDY.
Notify.Api.Factory

function TNotifyApiFactory.Api: INotifyApi;
begin
  {$IFDEF NTFY_HTTP_INDY}
  Result := TNotifyApiIndy.New
  {$ELSE}
  Result := TNotifyApiNetHTTP.New;
  {$IFEND}
end;

Without this compiler directive, the library will utilize NetHTTP by default. The developer can alter accessing Project > Options > Building > Delphi Compiler > Conditional Defines and adding NTFY_HTTP_INDY on the conditional defines list.

  • Sample directory was renamed to samples, so that the dependency manager ignores this folder when installing, avoiding the units inside this directory to be added on the project's search path.

  • A new example was included demonstrating how utilizing this library on windows services.

  • Two warnings were also removed at Notify.Api.Indy unit. They were caused by implicit cast operation when a string variable was assigned to a UTF8String variable.

LStrings := SplitString(UTF8ToString(LEventString) , #$A);

  for LString in LStrings do
    NxHorizon.Instance.Post<TNotifySubscriptionEvent>(Utf8String(LString));
  • TNotifyResponseData was renamed to TNotifyResponseDTO.

  • In case the developer opts to utilize Indy components, the openssl libraries will be loaded according to the operational sistem of the client. It has not yet been tested in some operational systems.

p-samuel avatar Jan 15 '23 21:01 p-samuel