2018-11-21 22:11:58 +01:00
|
|
|
program jsonrpcserverwithobjects;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
MVCFramework.Logger,
|
|
|
|
MVCFramework.Commons,
|
2020-08-06 17:40:56 +02:00
|
|
|
MVCFramework.Console,
|
2018-11-21 22:11:58 +01:00
|
|
|
MVCFramework.REPLCommandsHandlerU,
|
|
|
|
Web.ReqMulti,
|
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
|
|
|
IdHTTPWebBrokerBridge,
|
2022-07-25 15:32:31 +02:00
|
|
|
MVCFramework.Signal,
|
2018-11-21 22:11:58 +01:00
|
|
|
MyObjectU in 'MyObjectU.pas',
|
|
|
|
MainWebModuleU in 'MainWebModuleU.pas' {MyWebModule: TWebModule},
|
|
|
|
MVCFramework.JSONRPC in '..\..\sources\MVCFramework.JSONRPC.pas',
|
|
|
|
BusinessObjectsU in '..\commons\BusinessObjectsU.pas',
|
|
|
|
RandomUtilsU in '..\commons\RandomUtilsU.pas',
|
2022-07-11 00:09:59 +02:00
|
|
|
MainDM in '..\articles_crud_server\MainDM.pas' {dmMain: TDataModule},
|
|
|
|
CommonTypesU in 'CommonTypesU.pas';
|
2018-11-21 22:11:58 +01:00
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
var
|
|
|
|
lServer: TIdHTTPWebBrokerBridge;
|
|
|
|
begin
|
|
|
|
Writeln('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
|
2022-06-23 20:24:57 +02:00
|
|
|
Writeln('JSON-RPC Server with Published Objects');
|
2018-11-21 22:11:58 +01:00
|
|
|
|
|
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
|
|
try
|
|
|
|
LServer.DefaultPort := APort;
|
|
|
|
|
|
|
|
{ more info about MaxConnections
|
|
|
|
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_MaxConnections.html }
|
|
|
|
LServer.MaxConnections := 0;
|
|
|
|
|
|
|
|
{ more info about ListenQueue
|
|
|
|
http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdCustomTCPServer_ListenQueue.html }
|
|
|
|
LServer.ListenQueue := 200;
|
|
|
|
|
2022-06-23 20:24:57 +02:00
|
|
|
lServer.Active := True;
|
2022-07-25 15:32:31 +02:00
|
|
|
Write('CTRL+C to quit...');
|
|
|
|
WaitForTerminationSignal;
|
2018-11-21 22:11:58 +01:00
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
IsMultiThread := True;
|
2020-08-06 17:40:56 +02:00
|
|
|
TextColor(TConsoleColor.White);
|
2018-11-21 22:11:58 +01:00
|
|
|
try
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
|
|
WebRequestHandlerProc.MaxConnections := 1024;
|
|
|
|
RunServer(8080);
|
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
end;
|
|
|
|
end.
|