mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
68 lines
1.8 KiB
ObjectPascal
68 lines
1.8 KiB
ObjectPascal
program SSEIndyBasedSample;
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
uses
|
|
System.SysUtils,
|
|
MVCFramework,
|
|
MVCFramework.Signal,
|
|
MVCFramework.Logger,
|
|
MVCFramework.Commons,
|
|
{$IFDEF MSWINDOWS}
|
|
Winapi.Windows,
|
|
Winapi.ShellAPI,
|
|
{$ENDIF}
|
|
ReqMulti,
|
|
Web.WebReq,
|
|
Web.WebBroker,
|
|
IdHTTPWebBrokerBridge,
|
|
SSEControllerU in 'SSEControllerU.pas',
|
|
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} ,
|
|
StorageU in 'StorageU.pas';
|
|
|
|
{$R *.res}
|
|
|
|
procedure RunServer(APort: Integer);
|
|
var
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
begin
|
|
Writeln('** DMVCFramework Server ** build ' + DMVCFRAMEWORK_VERSION);
|
|
Writeln(Format('Starting HTTP Server on port %d', [APort]));
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
try
|
|
LServer.KeepAlive := True;
|
|
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;
|
|
LServer.Active := True;
|
|
{ Comment the next line to avoid the default browser startup }
|
|
{$IFDEF MSWINDOWS}
|
|
ShellExecute(0, 'open', PChar('http://localhost:' + inttostr(APort) + '/static'), nil, nil, SW_SHOWMAXIMIZED);
|
|
{$ENDIF}
|
|
Write('CTRL+C to stop the server');
|
|
WaitForTerminationSignal;
|
|
EnterInShutdownState;
|
|
finally
|
|
LServer.Free;
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
IsMultiThread := True;
|
|
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.
|