mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-16 00:05:53 +01:00
67 lines
1.3 KiB
ObjectPascal
67 lines
1.3 KiB
ObjectPascal
|
unit ServiceU;
|
||
|
|
||
|
interface
|
||
|
|
||
|
uses
|
||
|
Winapi.Windows,
|
||
|
Winapi.Messages,
|
||
|
System.SysUtils,
|
||
|
System.Classes,
|
||
|
Vcl.Graphics,
|
||
|
Vcl.Controls,
|
||
|
Vcl.SvcMgr,
|
||
|
Vcl.Dialogs,
|
||
|
IdHTTPWebBrokerBridge;
|
||
|
|
||
|
type
|
||
|
TArticlesService = class(TService)
|
||
|
procedure ServiceCreate(Sender: TObject);
|
||
|
procedure ServiceStart(Sender: TService; var Started: Boolean);
|
||
|
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
|
||
|
private
|
||
|
fServer: TIdHTTPWebBrokerBridge;
|
||
|
public
|
||
|
function GetServiceController: TServiceController; override;
|
||
|
end;
|
||
|
|
||
|
var
|
||
|
ArticlesService: TArticlesService;
|
||
|
|
||
|
implementation
|
||
|
|
||
|
uses
|
||
|
Web.WebReq,
|
||
|
WebModuleUnit1;
|
||
|
|
||
|
{$R *.DFM}
|
||
|
|
||
|
procedure ServiceController(CtrlCode: DWord); stdcall;
|
||
|
begin
|
||
|
ArticlesService.Controller(CtrlCode);
|
||
|
end;
|
||
|
|
||
|
function TArticlesService.GetServiceController: TServiceController;
|
||
|
begin
|
||
|
Result := ServiceController;
|
||
|
end;
|
||
|
|
||
|
procedure TArticlesService.ServiceCreate(Sender: TObject);
|
||
|
begin
|
||
|
if WebRequestHandler <> nil then
|
||
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
||
|
end;
|
||
|
|
||
|
procedure TArticlesService.ServiceStart(Sender: TService; var Started: Boolean);
|
||
|
begin
|
||
|
fServer := TIdHTTPWebBrokerBridge.Create(nil);
|
||
|
fServer.DefaultPort := 8080;
|
||
|
fServer.Active := True;
|
||
|
end;
|
||
|
|
||
|
procedure TArticlesService.ServiceStop(Sender: TService; var Stopped: Boolean);
|
||
|
begin
|
||
|
fServer.Free;
|
||
|
end;
|
||
|
|
||
|
end.
|