Changeset 357 for Network/CoolWeb/WebServer/UWebApp.pas
- Timestamp:
- Apr 29, 2012, 9:41:43 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Network/CoolWeb/WebServer/UWebApp.pas
r311 r357 7 7 uses 8 8 Classes, SysUtils, CustApp, SpecializedList, UWebPage, UHTTPSessionFile, 9 UHTTPServer ;9 UHTTPServer, Forms; 10 10 11 11 type 12 THTTPServerType = (stCGI, stTCP );12 THTTPServerType = (stCGI, stTCP, stTurboPower); 13 13 14 14 TRegistredPage = class … … 25 25 { TWebApp } 26 26 27 TWebApp = class(TC ustomApplication)27 TWebApp = class(TComponent) 28 28 private 29 29 FOnBeforePageProduce: TOnProduceEvent; 30 30 FOnInitialize: TNotifyEvent; 31 31 FServerType: THTTPServerType; 32 procedure DoRun; override;33 32 function DumpExceptionCallStack(E: Exception): string; 34 33 procedure HTTPServerRequest(HandlerData: THTTPHandlerData); … … 39 38 HTTPSessionStorageFile: THTTPSessionStorageFile; 40 39 LogException: Boolean; 41 procedure ShowException(E: Exception); override;40 procedure ShowException(E: Exception); 42 41 procedure RegisterPage(PageClass: TWebPageClass; out Reference; Path: string); 43 42 constructor Create(AOwner: TComponent); override; 44 43 destructor Destroy; override; 44 procedure Run; 45 published 45 46 property OnBeforePageProduce: TOnProduceEvent read FOnBeforePageProduce write FOnBeforePageProduce; 46 47 property OnInitialize: TNotifyEvent read FOnInitialize write FOnInitialize; … … 51 52 procedure Register; 52 53 53 var54 Application: TWebApp;55 56 57 54 implementation 58 55 59 56 uses 60 UHTTPServerCGI, UHTTPServerTCP ;57 UHTTPServerCGI, UHTTPServerTCP, UHTTPServerTurboPower; 61 58 62 59 resourcestring … … 66 63 procedure Register; 67 64 begin 68 RegisterC lass(TWebApp);65 RegisterComponents('CoolWeb', [TWebApp]); 69 66 end; 70 67 … … 84 81 { TWebApp } 85 82 86 procedure TWebApp. DoRun;83 procedure TWebApp.Run; 87 84 begin 88 try 89 if Assigned(FOnInitialize) then FOnInitialize(Self); 90 HTTPServer.Run; 91 finally 92 Terminate; 93 end; 85 if Assigned(FOnInitialize) then FOnInitialize(Self); 86 HTTPServer.Run; 87 if (ServerType = stCGI) or (ServerType = stTCP) then 88 Application.Terminate; 94 89 end; 95 90 … … 155 150 stCGI: HTTPServer := THTTPServerCGI.Create(nil); 156 151 stTCP: HTTPServer := THTTPServerTCP.Create(nil); 152 stTurboPower: HTTPServer := THTTPServerTurboPower.Create(nil); 157 153 end; 158 154 HTTPServer.OnRequest := HTTPServerRequest; … … 198 194 initialization 199 195 200 Application := TWebApp.Create(nil);201 202 203 196 finalization 204 205 Application.Free;206 197 207 198 end.
Note:
See TracChangeset
for help on using the changeset viewer.