THttpAsyncServer使用

THttpAsyncServer使用

unit Unit1;

interface

uses
  mormot.net.async,  mormot.net.http, mormot.net.server,
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    server: THttpAsyncServer;
    function process(Ctxt: THttpServerRequestAbstract): cardinal;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  var port: UTF8String := '1234';
  var threadPoolCount: Integer := 32;
  var KeepAliveTimeOut: Integer := 30000;
  server := THttpAsyncServer.Create(port, nil, nil, 'yn', threadPoolCount, KeepAliveTimeOut, [hsoNoXPoweredHeader]);
  var queueLen: Integer := 1000;
  server.HttpQueueLength := queueLen;
  server.OnRequest := process;
  server.WaitStarted();
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FreeAndNil(server);
end;

function TForm1.process(Ctxt: THttpServerRequestAbstract): cardinal;
begin

end;

end.

 

posted @ 2023-01-17 14:42  delphi中间件  阅读(372)  评论(0编辑  收藏  举报