Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
servercontroller -> Onclose session call to url
#2
IntraWeb has utility classes to perform this task:

Code:
implementation

{$R *.dfm}

uses
  IWInit, IWGlobal, IW.Common.Threads, IW.HTTP.IndyClient;

{ TIWServerController }

procedure TIWServerController.IWServerControllerBaseCloseSession(
  aSession: TIWApplication);
begin
  if Assigned(aSession) then
  begin
    TIWThreadBase.ExecInThread(
      procedure (AThread: TObject)
      var
        IndyClient: TIWHTTPClient;
      begin
        IndyClient := TIWHTTPClient.Create;
        try
          IndyClient.Get('http(s)://yourserver.com/theurl');
          // or
          // IndyClient.Post('http(s)://yoursever.com/theurl', 'Param1=Value1');  // there are 2 other overloads of this
        finally
          IndyClient.Free;
        end;
      end,
      'Thread_' + aSession.AppID);  // <- the name of the thread is just nice to have
  end;
end;

In this code I use the TIWHttpClient to send a GET or POST request to some arbitrary URL from a Thread (so it won't block the termination of the session - have in mind that connection to a different server, especially using HTTPS, can take a long time).

HTTPS connections also require OpenSSL DLLs available in the same directory where your application is.
Reply


Messages In This Thread
RE: servercontroller -> Onclose session call to url - by Alexandre Machado - 08-31-2021, 11:02 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)