Recent

Author Topic: Can't Access TFPCustomHttpServer.ConnectionHandler (Identifier not found)  (Read 408 times)

pewpew_soldat

  • Newbie
  • Posts: 2
I would like to hard shutdown a TFPCustomHttpServer without waiting. I think it would be possible to do this by calling the ConnectionHandler protected property's CloseSockets method if I could access it through code like this:

Code: Pascal  [Select][+][-]
  1. program main;
  2.  
  3. {$mode Delphi}
  4.  
  5. uses
  6.   FPHttpServer;
  7.  
  8. type
  9.   MyHttpServer = class(TFPCustomHttpServer)
  10.   public
  11.     procedure CloseSockets;
  12.   end;
  13.  
  14. procedure MyHttpServer.CloseSockets;
  15. begin
  16.   if Assigned(ConnectionHandler) then
  17.     ConnectionHandler.CloseSockets;
  18. end;
  19.  
  20. var
  21.   MyHttp: MyHttpServer;
  22. begin
  23.   MyHttp := MyHttpServer.Create(Nil);
  24.   MyHttp.CloseSockets;
  25.   MyHttp.Free;
  26. end.
  27.  

However that fails to compile with:

Code: [Select]
main.pas(16,15) Error: Identifier not found "ConnectionHandler"
main.pas(17,5) Error: Identifier not found "ConnectionHandler"

Any tips?

dsiders

  • Hero Member
  • *****
  • Posts: 1052
I would like to hard shutdown a TFPCustomHttpServer without waiting. I think it would be possible to do this by calling the ConnectionHandler protected property's CloseSockets method if I could access it through code like this:

Code: Pascal  [Select][+][-]
  1. program main;
  2.  
  3. {$mode Delphi}
  4.  
  5. uses
  6.   FPHttpServer;
  7.  
  8. type
  9.   MyHttpServer = class(TFPCustomHttpServer)
  10.   public
  11.     procedure CloseSockets;
  12.   end;
  13.  
  14. procedure MyHttpServer.CloseSockets;
  15. begin
  16.   if Assigned(ConnectionHandler) then
  17.     ConnectionHandler.CloseSockets;
  18. end;
  19.  
  20. var
  21.   MyHttp: MyHttpServer;
  22. begin
  23.   MyHttp := MyHttpServer.Create(Nil);
  24.   MyHttp.CloseSockets;
  25.   MyHttp.Free;
  26. end.
  27.  

However that fails to compile with:

Code: [Select]
main.pas(16,15) Error: Identifier not found "ConnectionHandler"
main.pas(17,5) Error: Identifier not found "ConnectionHandler"

Any tips?

Are you using a FPC 3.3.X (trunk) compiler? Because ConnectionHandler does not exist in 3.2.X versions.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

pewpew_soldat

  • Newbie
  • Posts: 2
Are you using a FPC 3.3.X (trunk) compiler? Because ConnectionHandler does not exist in 3.2.X versions.

Well that explains it, I'm on 3.2.2. I'm just looking through my local copy of the FPC source, and I hadn't checked out the appropriate tag (whoops). Thanks!

 

TinyPortal © 2005-2018