Added server side session with file persistence

This commit is contained in:
Daniele Teti 2023-08-12 01:24:10 +02:00
parent 8043616977
commit 85eef8920f
7 changed files with 1403 additions and 62 deletions

View File

@ -0,0 +1,102 @@
unit AppControllerU;
interface
uses
MVCFramework,
MVCFramework.Commons,
MVCFramework.Logger;
type
[MVCPath('/')]
TApp1MainController = class(TMVCController)
public
[MVCPath('/name')]
[MVCHTTPMethod([httpGET])]
procedure Index;
[MVCPath('/list')]
[MVCHTTPMethod([httpGET])]
procedure GetCustomSessionData;
[MVCPath('/login/($username)')]
[MVCHTTPMethod([httpGET])]
procedure DoLogin(username: String);
[MVCPath('/fruit/($nameOfFruit)')]
[MVCHTTPMethod([httpGET])]
procedure RegisterFruit(nameOfFruit: String);
[MVCPath('/logout')]
[MVCHTTPMethod([httpGET])]
procedure DoLogout;
end;
implementation
uses
System.SysUtils,
System.Classes;
{ TApp1MainController }
procedure TApp1MainController.DoLogin(username: String);
begin
Session['username'] := username;
ResponseStream
.AppendLine('Logged as ' + username)
.AppendLine
.AppendLine('in address of browser type: ')
.AppendLine('http://localhost:8080/list to check the current values in session ')
.AppendLine('http://localhost:8080/fruit/apple to register apple ')
.AppendLine('http://localhost:8080/fruit/banana to register banana ')
.AppendLine('http://localhost:8080/logout to end session ')
.AppendLine('http://localhost:8080/login/johndoe to login as johndoe');
RenderResponseStream;
end;
procedure TApp1MainController.RegisterFruit(nameOfFruit: String);
begin
Session[nameOfFruit] := nameOfFruit;
Redirect('/list');
end;
procedure TApp1MainController.DoLogout;
begin
Context.SessionStop(false);
Render('Logout');
end;
procedure TApp1MainController.GetCustomSessionData;
var
I: Integer;
lList: TArray<String>;
begin
lList := Session.Keys;
ResponseStream.AppendLine('List of fruits:');
for I := 0 to Length(lList) - 1 do
begin
ResponseStream.AppendLine(IntToStr(I + 1) + '-' + Session[lList[I]]);
end;
RenderResponseStream;
end;
procedure TApp1MainController.Index;
begin
ContentType := TMVCMediaType.TEXT_PLAIN;
// do not create session if not already created
if Context.SessionStarted then
begin
// automaticaly create the session
Render('Session[''username''] = ' + Session['username']);
end
else
begin
Render(400, 'Session not created. Do login first');
end;
end;
end.

View File

@ -0,0 +1,55 @@
program FileBasedSessionSample;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
MVCFramework,
MVCFramework.Signal,
{$IFDEF MSWINDOWS}
Winapi.Windows,
Winapi.ShellAPI,
{$ENDIF }
Web.WebReq,
Web.WebBroker,
IdHTTPWebBrokerBridge,
WebModuleUnit1 in 'WebModuleUnit1.pas' {WebModule1: TWebModule},
AppControllerU in 'AppControllerU.pas';
{$R *.res}
procedure RunServer(APort: Integer);
var
LServer: TIdHTTPWebBrokerBridge;
begin
Writeln(Format('Starting HTTP Server or port %d', [APort]));
LServer := TIdHTTPWebBrokerBridge.Create(nil);
try
LServer.DefaultPort := APort;
LServer.Active := True;
{$IFDEF MSWINDOWS}
//ShellExecute(0, 'open', PChar('http://localhost:' + IntToStr(APort) + '/login/john'), nil, nil, SW_SHOW);
{$ENDIF}
Writeln('CTRL+C to stop the server');
WaitForTerminationSignal;
EnterInShutdownState;
finally
LServer.Free;
end;
end;
begin
ReportMemoryLeaksOnShutdown := 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.

View File

@ -0,0 +1,899 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{F9CBCE21-869A-478F-992C-88FCAC97BC8B}</ProjectGuid>
<ProjectVersion>19.5</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>FileBasedSessionSample.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Console</AppType>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
<Base_Win64>true</Base_Win64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
<Cfg_1_Win32>true</Cfg_1_Win32>
<CfgParent>Cfg_1</CfgParent>
<Cfg_1>true</Cfg_1>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
<SanitizedProjectName>FileBasedSessionSample</SanitizedProjectName>
<DCC_UnitSearchPath>..\..\sources;..\..\lib\delphistompclient;..\..\lib\loggerpro;..\..\lib\dmustache;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Manifest_File>None</Manifest_File>
<VerInfo_Locale>1040</VerInfo_Locale>
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
<DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
<DCC_E>false</DCC_E>
<DCC_N>false</DCC_N>
<DCC_S>false</DCC_S>
<DCC_F>false</DCC_F>
<DCC_K>false</DCC_K>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_UsePackage>cxPivotGridChartRS17;JvMM;dxSkinSevenRS17;dxSkinBlueprintRS17;dxSkinHighContrastRS17;dxSkinOffice2007BlackRS17;dxCoreRS17;cxPageControldxBarPopupMenuRS17;dxSkinXmas2008BlueRS17;dxPSDBTeeChartRS17;JvCrypt;dxPSTeeChartRS17;dxSkinSummer2008RS17;dxPScxSchedulerLnkRS17;dxSkinBlueRS17;dxSkinDarkRoomRS17;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;dxPScxTLLnkRS17;JvNet;JvDotNetCtrls;dxRibbonRS17;DbxCommonDriver;cxDataRS17;vclimg;dxSkinsdxBarPainterRS17;dxPSdxDBTVLnkRS17;dbxcds;DatasnapConnectorsFreePascal;NxDBGridDsgn_dxe3;JvXPCtrls;dxSkinMoneyTwinsRS17;vcldb;cxExportRS17;dxPSCoreRS17;dxBarExtItemsRS17;dxGDIPlusRS17;FMXfrx17;dxNavBarRS17;CustomIPTransport;cxLibraryRS17;cxGridRS17;dxSkinOffice2010BlackRS17;dsnap;IndyIPServer;IndyCore;dxSkinMcSkinRS17;CloudService;dxPScxCommonRS17;FmxTeeUI;frxDB17;AnyDAC_PhysDb2_D17;dxSkinsdxDLPainterRS17;dxSkiniMaginaryRS17;JvDB;JvRuntimeDesign;dxPScxVGridLnkRS17;JclDeveloperTools;dxSkinSevenClassicRS17;dxPScxExtCommonRS17;MyFrameTestPackage;dxPScxSSLnkRS17;NxGridRun_dxe3;dxSkinLilianRS17;fs17;dxPSdxLCLnkRS17;dxSkinOffice2010BlueRS17;NxCommonRun_dxe3;bindcompfmx;DataBindingsVCL170;dxSkinOffice2010SilverRS17;vcldbx;cxSchedulerGridRS17;dbrtl;bindcomp;inetdb;JvPluginSystem;dxBarRS17;DataBindings;DBXOdbcDriver;IcsCommonDXE3Run;JvCmp;dxBarDBNavRS17;dxSkinWhiteprintRS17;JvTimeFramework;xmlrtl;dxSkinsdxRibbonPainterRS17;ibxpress;dxDockingRS17;vclactnband;bindengine;soaprtl;FMXTee;dxADOServerModeRS17;bindcompvcl;dxBarExtDBItemsRS17;dxPSPrVwRibbonRS17;Jcl;vclie;dxSkinOffice2007PinkRS17;cxPageControlRS17;dxSkinscxPCPainterRS17;AnyDAC_PhysADS_D17;AnyDAC_PhysIB_D17;dxmdsRS17;dxSkinTheAsphaltWorldRS17;DBXInformixDriver;Intraweb;dxPsPrVwAdvRS17;NxInspectorRun_dxe3;dxSkinSilverRS17;dxdborRS17;dsnapcon;DBXFirebirdDriver;fsDB17;inet;dorm_runtime_xe3;JvPascalInterpreter;vclx;dxSkinStardustRS17;cxEditorsRS17;DBXSybaseASADriver;NxInspectorDsgn_dxe3;dbexpress;IndyIPClient;AnyDAC_PhysMySQL_D17;cxTreeListdxBarPopupMenuRS17;dxSkinVS2010RS17;NxGridDsgn_dxe3;dxThemeRS17;DBXSqliteDriver;dxPScxGridLnkRS17;fmx;JvDlgs;IndySystem;TeeDB;dxSkinValentineRS17;vclib;inetdbbde;DataSnapClient;dxSkinDevExpressStyleRS17;DataSnapProviderClient;DBXSybaseASEDriver;cxBarEditItemRS17;AnyDAC_PhysMSAcc_D17;dxServerModeRS17;cxPivotGridOLAPRS17;cxSchedulerRS17;MetropolisUILiveTile;AnyDAC_PhysSQLITE_D17;dxPSLnksRS17;dxSkinPumpkinRS17;dxPSdxDBOCLnkRS17;cxVerticalGridRS17;dxSkinSpringTimeRS17;vcldsnap;dxSkinDevExpressDarkStyleRS17;DBXDb2Driver;AnyDAC_ComI_D17;DBXOracleDriver;AnyDAC_PhysMSSQL_D17;JvCore;NxDBGridRun_dxe3;vclribbon;AnyDAC_Comp_D17;cxSpreadSheetRS17;dxSkinLiquidSkyRS17;AnyDAC_PhysODBC_D17;fmxase;vcl;dxSkinOffice2007SilverRS17;AnyDAC_PhysPg_D17;IndyIPCommon;DBXMSSQLDriver;CodeSiteExpressPkg;dxPSdxOCLnkRS17;dcldxSkinsCoreRS17;JvAppFrm;AnyDAC_PhysASA_D17;inetdbxpress;webdsnap;NxCollectionRun_dxe3;AnyDAC_PhysOracle_D17;dxSkinCoffeeRS17;JvDocking;adortl;dxSkinscxSchedulerPainterRS17;JvWizards;NxCollectionDsgn_dxe3;frx17;NxCommonDsgn_dxe3;dxtrmdRS17;dxPScxPCProdRS17;AnyDAC_GUIxForms_D17;JvBands;rtl;DbxClientDriver;AnyDAC_PhysTDBX_D17;dxTabbedMDIRS17;dxComnRS17;dxSkinSharpPlusRS17;dxSkinsCoreRS17;dxSkinLondonLiquidSkyRS17;dxdbtrRS17;Tee;JclContainers;NxAddonsRun_dxe3;CPortLibDXE;JvSystem;dxorgcRS17;svnui;dxSkinBlackRS17;JvControls;NxSheetRun_dxe3;IndyProtocols;DBXMySQLDriver;dxLayoutControlRS17;bindcompdbx;TeeUI;JvJans;JvPrintPreview;JvPageComps;JvStdCtrls;JvCustom;dxSkinOffice2007BlueRS17;dxPScxPivotGridLnkRS17;dxSpellCheckerRS17;vcltouch;dxSkinOffice2007GreenRS17;dxSkinSharpRS17;websnap;dxSkinFoggyRS17;dxTileControlRS17;VclSmp;FMXfrxDB17;dxSkinDarkSideRS17;cxPivotGridRS17;DataSnapConnectors;AnyDAC_Phys_D17;fmxobj;SynEdit_RXE3;JclVcl;cxTreeListRS17;dxPSdxFCLnkRS17;dxSkinGlassOceansRS17;frxe17;svn;dxFlowChartRS17;fmxdae;dxSkinsdxNavBarPainterRS17;bdertl;VirtualTreesR;DataSnapIndy10ServerTransport;dxDBXServerModeRS17;dxSkinCaramelRS17;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win64)'!=''">
<DCC_UsePackage>cxPivotGridChartRS17;JvMM;dxSkinSevenRS17;dxSkinBlueprintRS17;dxSkinHighContrastRS17;dxSkinOffice2007BlackRS17;dxCoreRS17;cxPageControldxBarPopupMenuRS17;dxSkinXmas2008BlueRS17;dxPSDBTeeChartRS17;JvCrypt;dxPSTeeChartRS17;dxSkinSummer2008RS17;dxPScxSchedulerLnkRS17;dxSkinBlueRS17;dxSkinDarkRoomRS17;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;dxPScxTLLnkRS17;JvNet;dxRibbonRS17;DbxCommonDriver;cxDataRS17;vclimg;dxSkinsdxBarPainterRS17;dxPSdxDBTVLnkRS17;dbxcds;DatasnapConnectorsFreePascal;NxDBGridDsgn_dxe3;dxSkinMoneyTwinsRS17;vcldb;cxExportRS17;dxPSCoreRS17;dxBarExtItemsRS17;dxGDIPlusRS17;dxNavBarRS17;CustomIPTransport;cxLibraryRS17;cxGridRS17;dxSkinOffice2010BlackRS17;dsnap;IndyIPServer;IndyCore;dxSkinMcSkinRS17;dxPScxCommonRS17;AnyDAC_PhysDb2_D17;dxSkinsdxDLPainterRS17;dxSkiniMaginaryRS17;JvDB;dxPScxVGridLnkRS17;dxSkinSevenClassicRS17;dxPScxExtCommonRS17;dxPScxSSLnkRS17;NxGridRun_dxe3;dxSkinLilianRS17;dxPSdxLCLnkRS17;dxSkinOffice2010BlueRS17;NxCommonRun_dxe3;bindcompfmx;dxSkinOffice2010SilverRS17;cxSchedulerGridRS17;dbrtl;bindcomp;inetdb;JvPluginSystem;dxBarRS17;DBXOdbcDriver;JvCmp;dxBarDBNavRS17;dxSkinWhiteprintRS17;JvTimeFramework;xmlrtl;dxSkinsdxRibbonPainterRS17;ibxpress;dxDockingRS17;vclactnband;bindengine;soaprtl;dxADOServerModeRS17;bindcompvcl;dxBarExtDBItemsRS17;dxPSPrVwRibbonRS17;vclie;dxSkinOffice2007PinkRS17;cxPageControlRS17;dxSkinscxPCPainterRS17;AnyDAC_PhysADS_D17;AnyDAC_PhysIB_D17;dxmdsRS17;dxSkinTheAsphaltWorldRS17;DBXInformixDriver;dxPsPrVwAdvRS17;NxInspectorRun_dxe3;dxSkinSilverRS17;dxdborRS17;dsnapcon;DBXFirebirdDriver;inet;JvPascalInterpreter;vclx;dxSkinStardustRS17;cxEditorsRS17;DBXSybaseASADriver;NxInspectorDsgn_dxe3;dbexpress;IndyIPClient;AnyDAC_PhysMySQL_D17;cxTreeListdxBarPopupMenuRS17;dxSkinVS2010RS17;NxGridDsgn_dxe3;dxThemeRS17;DBXSqliteDriver;dxPScxGridLnkRS17;fmx;JvDlgs;IndySystem;TeeDB;dxSkinValentineRS17;vclib;DataSnapClient;dxSkinDevExpressStyleRS17;DataSnapProviderClient;DBXSybaseASEDriver;cxBarEditItemRS17;AnyDAC_PhysMSAcc_D17;dxServerModeRS17;cxPivotGridOLAPRS17;cxSchedulerRS17;AnyDAC_PhysSQLITE_D17;dxPSLnksRS17;dxSkinPumpkinRS17;dxPSdxDBOCLnkRS17;cxVerticalGridRS17;dxSkinSpringTimeRS17;vcldsnap;dxSkinDevExpressDarkStyleRS17;DBXDb2Driver;AnyDAC_ComI_D17;DBXOracleDriver;AnyDAC_PhysMSSQL_D17;JvCore;NxDBGridRun_dxe3;AnyDAC_Comp_D17;cxSpreadSheetRS17;dxSkinLiquidSkyRS17;AnyDAC_PhysODBC_D17;fmxase;vcl;dxSkinOffice2007SilverRS17;AnyDAC_PhysPg_D17;IndyIPCommon;DBXMSSQLDriver;dxPSdxOCLnkRS17;dcldxSkinsCoreRS17;JvAppFrm;AnyDAC_PhysASA_D17;inetdbxpress;webdsnap;NxCollectionRun_dxe3;AnyDAC_PhysOracle_D17;dxSkinCoffeeRS17;adortl;dxSkinscxSchedulerPainterRS17;JvWizards;NxCollectionDsgn_dxe3;NxCommonDsgn_dxe3;dxtrmdRS17;dxPScxPCProdRS17;AnyDAC_GUIxForms_D17;JvBands;rtl;DbxClientDriver;AnyDAC_PhysTDBX_D17;dxTabbedMDIRS17;dxComnRS17;dxSkinSharpPlusRS17;dxSkinsCoreRS17;dxSkinLondonLiquidSkyRS17;dxdbtrRS17;Tee;NxAddonsRun_dxe3;JvSystem;dxorgcRS17;dxSkinBlackRS17;JvControls;NxSheetRun_dxe3;IndyProtocols;DBXMySQLDriver;dxLayoutControlRS17;bindcompdbx;TeeUI;JvJans;JvPrintPreview;JvPageComps;JvStdCtrls;JvCustom;dxSkinOffice2007BlueRS17;dxPScxPivotGridLnkRS17;dxSpellCheckerRS17;vcltouch;dxSkinOffice2007GreenRS17;dxSkinSharpRS17;websnap;dxSkinFoggyRS17;dxTileControlRS17;VclSmp;dxSkinDarkSideRS17;cxPivotGridRS17;DataSnapConnectors;AnyDAC_Phys_D17;fmxobj;SynEdit_RXE3;cxTreeListRS17;dxPSdxFCLnkRS17;dxSkinGlassOceansRS17;dxFlowChartRS17;fmxdae;dxSkinsdxNavBarPainterRS17;DataSnapIndy10ServerTransport;dxDBXServerModeRS17;dxSkinCaramelRS17;$(DCC_UsePackage)</DCC_UsePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
<DCC_DebugDCUs>true</DCC_DebugDCUs>
<DCC_Optimize>false</DCC_Optimize>
<DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
<DCC_RemoteDebug>true</DCC_RemoteDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<DCC_MapFile>3</DCC_MapFile>
<DCC_ConsoleTarget>true</DCC_ConsoleTarget>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_DebugInformation>0</DCC_DebugInformation>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="WebModuleUnit1.pas">
<Form>WebModule1</Form>
<DesignClass>TWebModule</DesignClass>
</DCCReference>
<DCCReference Include="AppControllerU.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Debug">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Delphi.Personality>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1040</VersionInfo>
<VersionInfo Name="CodePage">1252</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
<VersionInfoKeys Name="OriginalFilename"/>
<VersionInfoKeys Name="ProductName"/>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"/>
<VersionInfoKeys Name="CFBundleName"/>
<VersionInfoKeys Name="CFBundleDisplayName"/>
<VersionInfoKeys Name="CFBundleIdentifier"/>
<VersionInfoKeys Name="CFBundleVersion"/>
<VersionInfoKeys Name="CFBundlePackageType"/>
<VersionInfoKeys Name="CFBundleSignature"/>
<VersionInfoKeys Name="CFBundleAllowMixedLocalizations"/>
<VersionInfoKeys Name="CFBundleExecutable"/>
</VersionInfoKeys>
<Source>
<Source Name="MainSource">FileBasedSessionSample.dpr</Source>
</Source>
<Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k170.bpl">Microsoft Office 2000 Beispiele für gekapselte Komponenten für Automatisierungsserver</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp170.bpl">Microsoft Office XP Beispiele für gekapselte Komponenten für Automation Server</Excluded_Packages>
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="4">
<DeployFile LocalName="Win32\Debug\FileBasedSessionSample.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>FileBasedSessionSample.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win32\Debug\SessionSample.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployClass Name="AdditionalDebugSymbols">
<Platform Name="OSX32">
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidClasses">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidFileProvider">
<Platform Name="Android">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\xml</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidGDBServer">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiFile">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeArmeabiv7aFile">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidLibnativeMipsFile">
<Platform Name="Android">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\mips</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidServiceOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashImageDef">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStyles">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidSplashStylesV21">
<Platform Name="Android">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values-v21</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Colors">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_DefaultAppIcon">
<Platform Name="Android">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon144">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon192">
<Platform Name="Android">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-ldpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_LauncherIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon24">
<Platform Name="Android">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-mdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon36">
<Platform Name="Android">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-hdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon48">
<Platform Name="Android">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon72">
<Platform Name="Android">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_NotificationIcon96">
<Platform Name="Android">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage426">
<Platform Name="Android">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-small</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage470">
<Platform Name="Android">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-normal</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage640">
<Platform Name="Android">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-large</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_SplashImage960">
<Platform Name="Android">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\drawable-xlarge</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="Android_Strings">
<Platform Name="Android">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>res\values</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DebugSymbols">
<Platform Name="iOSSimulator">
<Operation>1</Operation>
</Platform>
<Platform Name="OSX32">
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DependencyFramework">
<Platform Name="OSX32">
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="OSXARM64">
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="DependencyModule">
<Platform Name="OSX32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSXARM64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
</Platform>
</DeployClass>
<DeployClass Required="true" Name="DependencyPackage">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX32">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSXARM64">
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.bpl</Extensions>
</Platform>
</DeployClass>
<DeployClass Name="File">
<Platform Name="Android">
<Operation>0</Operation>
</Platform>
<Platform Name="Android64">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>0</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<Operation>0</Operation>
</Platform>
<Platform Name="OSX32">
<Operation>0</Operation>
</Platform>
<Platform Name="OSX64">
<Operation>0</Operation>
</Platform>
<Platform Name="OSXARM64">
<Operation>0</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectAndroidManifest">
<Platform Name="Android">
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXDebug"/>
<DeployClass Name="ProjectOSXEntitlements"/>
<DeployClass Name="ProjectOSXInfoPList"/>
<DeployClass Name="ProjectOSXResource">
<Platform Name="OSX32">
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSX64">
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Required="true" Name="ProjectOutput">
<Platform Name="Android">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>library\lib\arm64-v8a</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
</Platform>
<Platform Name="Linux64">
<Operation>1</Operation>
</Platform>
<Platform Name="OSX32">
<Operation>1</Operation>
</Platform>
<Platform Name="OSX64">
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOutput_Android32">
<Platform Name="Android64">
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectUWPManifest">
<Platform Name="Win32">
<Operation>1</Operation>
</Platform>
<Platform Name="Win64">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSDeviceDebug">
<Platform Name="iOSDevice32">
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectiOSEntitlements"/>
<DeployClass Name="ProjectiOSInfoPList"/>
<DeployClass Name="ProjectiOSLaunchScreen"/>
<DeployClass Name="ProjectiOSResource">
<Platform Name="iOSDevice32">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSDevice64">
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="UWP_DelphiLogo150">
<Platform Name="Win32">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Win64">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="UWP_DelphiLogo44">
<Platform Name="Win32">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Win64">
<RemoteDir>Assets</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iOS_AppStore1024">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_AppIcon152">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_AppIcon167">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Launch2x">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_LaunchDark2x">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Notification40">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_Setting58">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPad_SpotLight80">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_AppIcon120">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_AppIcon180">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch2x">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Launch3x">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_LaunchDark2x">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_LaunchDark3x">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Notification40">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Notification60">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Setting58">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Setting87">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Spotlight120">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="iPhone_Spotlight80">
<Platform Name="iOSDevice64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="iOSSimARM64">
<RemoteDir>..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Win32">True</Platform>
<Platform value="Win64">False</Platform>
</Platforms>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
<Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/>
</Project>

View File

@ -0,0 +1,11 @@
object WebModule1: TWebModule1
OnCreate = WebModuleCreate
Actions = <
item
Default = True
Name = 'DefaultHandler'
PathInfo = '/'
end>
Height = 230
Width = 415
end

View File

@ -0,0 +1,44 @@
unit WebModuleUnit1;
interface
uses
System.SysUtils,
System.Classes,
Web.HTTPApp,
MVCFramework;
type
TWebModule1 = class(TWebModule)
procedure WebModuleCreate(Sender: TObject);
private
MVC: TMVCEngine;
public
{ Public declarations }
end;
var
WebModuleClass: TComponentClass = TWebModule1;
implementation
{$R *.dfm}
uses AppControllerU, MVCFramework.Commons;
procedure TWebModule1.WebModuleCreate(Sender: TObject);
begin
MVC := TMVCEngine.Create(Self,
procedure(Config: TMVCConfig)
begin
Config[TMVCConfigKey.SessionTimeout] := '10'; // 10minutes
Config[TMVCConfigKey.DefaultContentType] := 'text/plain';
Config[TMVCConfigKey.SessionType] := 'file';
end);
MVC.AddController(TApp1MainController);
end;
end.

View File

@ -32,15 +32,18 @@ uses
System.SyncObjs, System.SyncObjs,
System.SysUtils, System.SysUtils,
System.DateUtils, System.DateUtils,
System.Generics.Collections; System.Generics.Collections, MVCFramework.Commons;
const const
DEFAULT_SESSION_INACTIVITY = 60; // in minutes DEFAULT_SESSION_INACTIVITY = 60; // in minutes
type type
EMVCSession = class(EMVCException)
TWebSession = class abstract end;
TMVCWebSession = class abstract
private private
FSessionId: string; FSessionId: string;
FLastAccess: TDateTime; FLastAccess: TDateTime;
@ -48,22 +51,25 @@ type
protected protected
function GetItems(const AKey: string): string; virtual; abstract; function GetItems(const AKey: string): string; virtual; abstract;
procedure SetItems(const AKey, AValue: string); virtual; abstract; procedure SetItems(const AKey, AValue: string); virtual; abstract;
procedure SetLastAccess(Value: TDateTime);
public public
constructor Create(const ASessionId: string; const ATimeout: UInt64); virtual; constructor Create(const ASessionId: string; const ATimeout: UInt64); virtual;
destructor Destroy; override; destructor Destroy; override;
procedure MarkAsUsed; virtual; procedure MarkAsUsed; virtual;
function ToString: string; override; function ToString: string; override;
function IsExpired: Boolean; virtual; function IsExpired: Boolean; virtual;
function Keys: TArray<String>; virtual; abstract;
class function TryFindSessionID(const ASessionID: String): Boolean; virtual;
class procedure TryDeleteSessionID(const ASessionID: String); virtual;
property Items[const AKey: string]: string read GetItems write SetItems; default; property Items[const AKey: string]: string read GetItems write SetItems; default;
property SessionId: string read FSessionId; property SessionId: string read FSessionId;
property LastAccess: TDateTime read FLastAccess; property LastAccess: TDateTime read FLastAccess;
property Timeout: UInt64 read FTimeout; property Timeout: UInt64 read FTimeout;
end; end;
TWebSessionClass = class of TWebSession; TMVCWebSessionClass = class of TMVCWebSession;
TWebSessionMemory = class(TWebSession) TMVCWebSessionMemory = class(TMVCWebSession)
private private
FData: TDictionary<string, string>; FData: TDictionary<string, string>;
protected protected
@ -72,37 +78,61 @@ type
public public
constructor Create(const ASessionId: string; const ATimeout: UInt64); override; constructor Create(const ASessionId: string; const ATimeout: UInt64); override;
destructor Destroy; override; destructor Destroy; override;
function ToString: string; override; function ToString: string; override;
property Data: TDictionary<string, string> read FData; property Data: TDictionary<string, string> read FData;
end; end;
TMVCWebSessionFile = class(TMVCWebSessionMemory)
private
fSessionFolder: String;
protected
procedure StartLoading;
procedure EndLoading;
function GetFileName: String; overload;
class function GetFileName(const SessionFolder, SessionID: String): String; overload;
procedure LoadFromFile;
procedure SaveToFile;
procedure OnValueNotify(Sender: TObject; const Item: String; Action: TCollectionNotification);
public
constructor Create(const SessionID: string; const Timeout: UInt64); override;
destructor Destroy; override;
function Keys: System.TArray<System.string>; override;
class function TryFindSessionID(const ASessionID: String): Boolean; override;
class procedure TryDeleteSessionID(const ASessionID: String); override;
end;
TMVCSessionFactory = class sealed TMVCSessionFactory = class sealed
private private
FRegisteredSessionTypes: TDictionary<string, TWebSessionClass>; FRegisteredSessionTypes: TDictionary<string, TMVCWebSessionClass>;
protected protected
class var cInstance: TMVCSessionFactory; class var cInstance: TMVCSessionFactory;
constructor Create; constructor Create;
public public
destructor Destroy; override; destructor Destroy; override;
procedure RegisterSessionType(const AName: string; AWebSessionClass: TWebSessionClass); procedure RegisterSessionType(const AName: string; AWebSessionClass: TMVCWebSessionClass);
function CreateNewByType(const AName, ASessionId: string; const ATimeout: UInt64): TWebSession; function CreateNewByType(const AName, ASessionId: string; const ATimeout: UInt64): TMVCWebSession;
function TryFindSessionID(const AName: string; const ASessionID: String): Boolean;
procedure TryDeleteSessionID(const AName: string; const ASessionID: String);
class function GetInstance: TMVCSessionFactory; static; class function GetInstance: TMVCSessionFactory; static;
// class procedure DestroyInstance; static; // class procedure DestroyInstance; static;
end; end;
function GlobalSessionList: TObjectDictionary<string, TWebSession>; function GlobalSessionList: TObjectDictionary<string, TMVCWebSession>;
implementation implementation
uses
System.IOUtils,
System.Classes,
MVCFramework.Serializer.Commons;
var var
GlSessionList: TObjectDictionary<string, TWebSession> = nil; GlSessionList: TObjectDictionary<string, TMVCWebSession> = nil;
GlLastSessionListClear: TDateTime; GlLastSessionListClear: TDateTime;
GlCriticalSection: TCriticalSection; GlCriticalSection: TCriticalSection;
function GlobalSessionList: TObjectDictionary<string, TWebSession>; function GlobalSessionList: TObjectDictionary<string, TMVCWebSession>;
var var
S: string; S: string;
begin begin
@ -111,7 +141,9 @@ begin
GlCriticalSection.Enter; GlCriticalSection.Enter;
try try
if not Assigned(GlSessionList) then if not Assigned(GlSessionList) then
GlSessionList := TObjectDictionary<string, TWebSession>.Create([doOwnsValues]); begin
GlSessionList := TObjectDictionary<string, TMVCWebSession>.Create([doOwnsValues]);
end;
finally finally
GlCriticalSection.Leave; GlCriticalSection.Leave;
end; end;
@ -122,7 +154,7 @@ begin
TMonitor.Enter(GlSessionList); TMonitor.Enter(GlSessionList);
try try
for S in GlSessionList.Keys do for S in GlSessionList.Keys do
if TWebSession(GlSessionList.Items[S]).IsExpired then if TMVCWebSession(GlSessionList.Items[S]).IsExpired then
GlSessionList.Remove(S); GlSessionList.Remove(S);
GlLastSessionListClear := Now; GlLastSessionListClear := Now;
finally finally
@ -135,19 +167,19 @@ end;
{ TWebSession } { TWebSession }
constructor TWebSession.Create(const ASessionId: string; const ATimeout: UInt64); constructor TMVCWebSession.Create(const ASessionId: string; const ATimeout: UInt64);
begin begin
inherited Create; inherited Create;
FSessionId := ASessionId; FSessionId := ASessionId;
FTimeout := ATimeout; FTimeout := ATimeout;
end; end;
destructor TWebSession.Destroy; destructor TMVCWebSession.Destroy;
begin begin
inherited Destroy; inherited Destroy;
end; end;
function TWebSession.IsExpired: Boolean; function TMVCWebSession.IsExpired: Boolean;
begin begin
if (FTimeout = 0) then if (FTimeout = 0) then
Result := MinutesBetween(Now, LastAccess) > DEFAULT_SESSION_INACTIVITY Result := MinutesBetween(Now, LastAccess) > DEFAULT_SESSION_INACTIVITY
@ -155,31 +187,46 @@ begin
Result := MinutesBetween(Now, LastAccess) > FTimeout; Result := MinutesBetween(Now, LastAccess) > FTimeout;
end; end;
procedure TWebSession.MarkAsUsed; procedure TMVCWebSession.MarkAsUsed;
begin begin
FLastAccess := Now; FLastAccess := Now;
end; end;
function TWebSession.ToString: string; procedure TMVCWebSession.SetLastAccess(Value: TDateTime);
begin
FLastAccess := Value;
end;
function TMVCWebSession.ToString: string;
begin begin
Result := ''; Result := '';
end; end;
class procedure TMVCWebSession.TryDeleteSessionID(const ASessionID: String);
begin
//do nothing
end;
class function TMVCWebSession.TryFindSessionID(const ASessionID: String): Boolean;
begin
Result := False;
end;
{ TWebSessionMemory } { TWebSessionMemory }
constructor TWebSessionMemory.Create(const ASessionId: string; const ATimeout: UInt64); constructor TMVCWebSessionMemory.Create(const ASessionId: string; const ATimeout: UInt64);
begin begin
inherited Create(ASessionId, ATimeout); inherited Create(ASessionId, ATimeout);
FData := TDictionary<string, string>.Create; FData := TDictionary<string, string>.Create;
end; end;
destructor TWebSessionMemory.Destroy; destructor TMVCWebSessionMemory.Destroy;
begin begin
FData.Free; FData.Free;
inherited Destroy; inherited Destroy;
end; end;
function TWebSessionMemory.GetItems(const AKey: string): string; function TMVCWebSessionMemory.GetItems(const AKey: string): string;
begin begin
TMonitor.Enter(Self); TMonitor.Enter(Self);
try try
@ -190,7 +237,7 @@ begin
end; end;
end; end;
procedure TWebSessionMemory.SetItems(const AKey, AValue: string); procedure TMVCWebSessionMemory.SetItems(const AKey, AValue: string);
begin begin
TMonitor.Enter(Self); TMonitor.Enter(Self);
try try
@ -200,7 +247,7 @@ begin
end; end;
end; end;
function TWebSessionMemory.ToString: string; function TMVCWebSessionMemory.ToString: string;
var var
LKey: string; LKey: string;
begin begin
@ -214,15 +261,15 @@ end;
constructor TMVCSessionFactory.Create; constructor TMVCSessionFactory.Create;
begin begin
inherited Create; inherited Create;
FRegisteredSessionTypes := TDictionary<string, TWebSessionClass>.Create; FRegisteredSessionTypes := TDictionary<string, TMVCWebSessionClass>.Create;
end; end;
function TMVCSessionFactory.CreateNewByType(const AName, ASessionId: string; const ATimeout: UInt64): TWebSession; function TMVCSessionFactory.CreateNewByType(const AName, ASessionId: string; const ATimeout: UInt64): TMVCWebSession;
var var
Clazz: TWebSessionClass; Clazz: TMVCWebSessionClass;
begin begin
if not FRegisteredSessionTypes.TryGetValue(AName, Clazz) then if not FRegisteredSessionTypes.TryGetValue(AName, Clazz) then
raise Exception.Create('Unknown application session type'); raise EMVCSession.Create('Unknown application session type: ' + AName);
Result := Clazz.Create(ASessionId, ATimeout); Result := Clazz.Create(ASessionId, ATimeout);
end; end;
@ -241,14 +288,164 @@ begin
Result := cInstance; Result := cInstance;
end; end;
procedure TMVCSessionFactory.RegisterSessionType(const AName: string; AWebSessionClass: TWebSessionClass); procedure TMVCSessionFactory.RegisterSessionType(const AName: string; AWebSessionClass: TMVCWebSessionClass);
begin begin
FRegisteredSessionTypes.AddOrSetValue(AName, AWebSessionClass); FRegisteredSessionTypes.AddOrSetValue(AName, AWebSessionClass);
end; end;
procedure TMVCSessionFactory.TryDeleteSessionID(const AName, ASessionID: String);
var
Clazz: TMVCWebSessionClass;
begin
if not FRegisteredSessionTypes.TryGetValue(AName, Clazz) then
raise EMVCSession.Create('Unknown application session type: ' + AName);
Clazz.TryDeleteSessionID(ASessionID);
end;
function TMVCSessionFactory.TryFindSessionID(const AName: string; const ASessionID: String): Boolean;
var
Clazz: TMVCWebSessionClass;
begin
if not FRegisteredSessionTypes.TryGetValue(AName, Clazz) then
raise EMVCSession.Create('Unknown application session type: ' + AName);
Result := Clazz.TryFindSessionID(ASessionID);
end;
{ TWebSessionMemoryController }
constructor TMVCWebSessionFile.Create(const SessionID: string; const Timeout: UInt64);
begin
inherited Create(SessionID, Timeout);
Data.OnValueNotify := OnValueNotify;
fSessionFolder := TPath.Combine(AppPath, 'sessions');
TDirectory.CreateDirectory(fSessionFolder);
LoadFromFile;
MarkAsUsed;
SaveToFile;
end;
destructor TMVCWebSessionFile.Destroy;
begin
inherited;
end;
procedure TMVCWebSessionFile.EndLoading;
begin
Data.OnValueNotify := OnValueNotify;
end;
class function TMVCWebSessionFile.GetFileName(const SessionFolder,
SessionID: String): String;
begin
Result := TPath.Combine(SessionFolder, SessionId);
end;
function TMVCWebSessionFile.GetFileName: String;
begin
Result := GetFileName(fSessionFolder, SessionId);
end;
function TMVCWebSessionFile.Keys: System.TArray<System.string>;
begin
Result := Data.Keys.ToArray;
end;
procedure TMVCWebSessionFile.LoadFromFile;
var
lFileName: String;
lFile: TStreamReader;
lLine: string;
lPieces: TArray<System.string>;
begin
lFileName := GetFileName;
if not TFile.Exists(lFileName) then
begin
Exit;
end;
//Log.Info('Loading session %s from %s', [SessionId, lFileName], 'file_session_events');
lFile := TFile.OpenText(lFileName);
try
StartLoading;
try
SetLastAccess(ISOTimeStampToDateTime(lFile.ReadLine));
while not lFile.EndOfStream do
begin
lLine := lFile.ReadLine;
lPieces := lLine.Split(['=']);
Data.Add(lPieces[0], lPieces[1]);
end;
finally
EndLoading;
end;
finally
lFile.Free;
end;
end;
procedure TMVCWebSessionFile.OnValueNotify(Sender: TObject; const Item: String;
Action: TCollectionNotification);
begin
if Action in [cnAdded, cnExtracted, cnRemoved] then
begin
//Log.Info('Saving session %s because item changed [%s]', [SessionId, Item], 'file_session_events');
SaveToFile;
end;
end;
procedure TMVCWebSessionFile.SaveToFile;
var
lFileName: String;
lPair: TPair<String, String>;
lFile: TStreamWriter;
begin
MarkAsUsed;
lFileName := GetFileName;
lFile := TFile.CreateText(lFileName);
try
lFile.WriteLine(DateTimeToISOTimeStamp(LastAccess));
for lPair in Data do
begin
lFile.WriteLine(String.Join('=', [lPair.Key, lPair.Value]));
end;
lFile.Close;
finally
lFile.Free;
end;
end;
procedure TMVCWebSessionFile.StartLoading;
begin
Data.OnValueNotify := nil;
end;
class procedure TMVCWebSessionFile.TryDeleteSessionID(const ASessionID: String);
var
lSessionFolder: string;
begin
inherited;
lSessionFolder := TPath.Combine(AppPath, 'sessions');
if TFile.Exists(GetFileName(lSessionFolder, ASessionID)) then
begin
TFile.Delete(GetFileName(lSessionFolder, ASessionID));
end;
end;
class function TMVCWebSessionFile.TryFindSessionID(
const ASessionID: String): Boolean;
var
lSessionFolder: string;
begin
inherited;
lSessionFolder := TPath.Combine(AppPath, 'sessions');
Result := TFile.Exists(GetFileName(lSessionFolder, ASessionID));
end;
initialization initialization
TMVCSessionFactory.GetInstance.RegisterSessionType('memory', TWebSessionMemory); TMVCSessionFactory.GetInstance.RegisterSessionType('memory', TMVCWebSessionMemory);
TMVCSessionFactory.GetInstance.RegisterSessionType('file', TMVCWebSessionFile);
GlCriticalSection := TCriticalSection.Create; GlCriticalSection := TCriticalSection.Create;
finalization finalization

View File

@ -505,8 +505,8 @@ type
function IsValid: Boolean; function IsValid: Boolean;
procedure Clear; procedure Clear;
procedure SaveToSession(const AWebSession: TWebSession); procedure SaveToSession(const AWebSession: TMVCWebSession);
function LoadFromSession(const AWebSession: TWebSession): Boolean; function LoadFromSession(const AWebSession: TMVCWebSession): Boolean;
property UserName: string read FUserName write FUserName; property UserName: string read FUserName write FUserName;
property Roles: TList<string> read FRoles; property Roles: TList<string> read FRoles;
@ -524,10 +524,10 @@ type
FIsSessionStarted: Boolean; FIsSessionStarted: Boolean;
FSessionMustBeClose: Boolean; FSessionMustBeClose: Boolean;
FLoggedUser: TUser; FLoggedUser: TUser;
FWebSession: TWebSession; FWebSession: TMVCWebSession;
FData: TMVCStringDictionary; FData: TMVCStringDictionary;
fIntfObject: IInterface; fIntfObject: IInterface;
function GetWebSession: TWebSession; function GetWebSession: TMVCWebSession;
function GetLoggedUser: TUser; function GetLoggedUser: TUser;
function GetParamsTable: TMVCRequestParamsTable; function GetParamsTable: TMVCRequestParamsTable;
procedure SetParamsTable(const AValue: TMVCRequestParamsTable); procedure SetParamsTable(const AValue: TMVCRequestParamsTable);
@ -540,14 +540,14 @@ type
procedure BindToSession(const ASessionId: string); procedure BindToSession(const ASessionId: string);
function SendSessionCookie(const AContext: TWebContext): string; function SendSessionCookie(const AContext: TWebContext): string;
function AddSessionToTheSessionList(const ASessionType, ASessionId: string; function AddSessionToTheSessionList(const ASessionType, ASessionId: string;
const ASessionTimeout: Integer): TWebSession; const ASessionTimeout: Integer): TMVCWebSession;
function GetData: TMVCStringDictionary; function GetData: TMVCStringDictionary;
public public
constructor Create(const ARequest: TWebRequest; const AResponse: TWebResponse; constructor Create(const ARequest: TWebRequest; const AResponse: TWebResponse;
const AConfig: TMVCConfig; const ASerializers: TDictionary<string, IMVCSerializer>); const AConfig: TMVCConfig; const ASerializers: TDictionary<string, IMVCSerializer>);
destructor Destroy; override; destructor Destroy; override;
procedure SessionStart; virtual; procedure SessionStart(const SessionType: String); virtual;
procedure SessionStop(const ARaiseExceptionIfExpired: Boolean = True); virtual; procedure SessionStop(const ARaiseExceptionIfExpired: Boolean = True); virtual;
function SessionStarted: Boolean; function SessionStarted: Boolean;
@ -559,7 +559,7 @@ type
property LoggedUser: TUser read GetLoggedUser; property LoggedUser: TUser read GetLoggedUser;
property Request: TMVCWebRequest read FRequest; property Request: TMVCWebRequest read FRequest;
property Response: TMVCWebResponse read FResponse; property Response: TMVCWebResponse read FResponse;
property Session: TWebSession read GetWebSession; property Session: TMVCWebSession read GetWebSession;
property Config: TMVCConfig read FConfig; property Config: TMVCConfig read FConfig;
property Data: TMVCStringDictionary read GetData; property Data: TMVCStringDictionary read GetData;
property CustomIntfObject: IInterface read GetIntfObject write SetIntfObject; property CustomIntfObject: IInterface read GetIntfObject write SetIntfObject;
@ -776,7 +776,7 @@ type
private private
FViewModel: TMVCViewDataObject; FViewModel: TMVCViewDataObject;
FViewDataSets: TMVCViewDataSet; FViewDataSets: TMVCViewDataSet;
function GetSession: TWebSession; function GetSession: TMVCWebSession;
function GetViewData(const aModelName: string): TObject; function GetViewData(const aModelName: string): TObject;
function GetViewDataset(const aDataSetName: string): TDataSet; function GetViewDataset(const aDataSetName: string): TDataSet;
procedure SetViewData(const aModelName: string; const Value: TObject); procedure SetViewData(const aModelName: string; const Value: TObject);
@ -812,7 +812,7 @@ type
/// </summary> /// </summary>
procedure LoadViewFragment(const AViewFragment: string); procedure LoadViewFragment(const AViewFragment: string);
function SessionAs<T: TWebSession>: T; function SessionAs<T: TMVCWebSession>: T;
procedure RaiseSessionExpired; virtual; procedure RaiseSessionExpired; virtual;
// Avoiding mid-air collisions - support // Avoiding mid-air collisions - support
@ -823,7 +823,7 @@ type
// Properties // Properties
property Context: TWebContext read GetContext write FContext; property Context: TWebContext read GetContext write FContext;
property Session: TWebSession read GetSession; property Session: TMVCWebSession read GetSession;
property ContentType: string read GetContentType write SetContentType; property ContentType: string read GetContentType write SetContentType;
property StatusCode: Integer read GetStatusCode write SetStatusCode; property StatusCode: Integer read GetStatusCode write SetStatusCode;
procedure PushObjectToView(const aModelName: string; const AModel: TObject); procedure PushObjectToView(const aModelName: string; const AModel: TObject);
@ -985,7 +985,7 @@ type
const AResponse: TWebResponse): Boolean; virtual; const AResponse: TWebResponse): Boolean; virtual;
public public
class function GetCurrentSession(const ASessionId: string; class function GetCurrentSession(const ASessionId: string;
const ARaiseExceptionIfExpired: Boolean = True): TWebSession; static; const ARaiseExceptionIfExpired: Boolean = True): TMVCWebSession; static;
class function ExtractSessionIdFromWebRequest(const AWebRequest: TWebRequest): string; static; class function ExtractSessionIdFromWebRequest(const AWebRequest: TWebRequest): string; static;
class function SendSessionCookie(const AContext: TWebContext): string; overload; static; class function SendSessionCookie(const AContext: TWebContext): string; overload; static;
class function SendSessionCookie(const AContext: TWebContext; const ASessionId: string): string; class function SendSessionCookie(const AContext: TWebContext; const ASessionId: string): string;
@ -996,7 +996,7 @@ type
const ACustomLogger: ILogWriter = nil); reintroduce; const ACustomLogger: ILogWriter = nil); reintroduce;
destructor Destroy; override; destructor Destroy; override;
function GetSessionBySessionId(const ASessionId: string): TWebSession; function GetSessionBySessionId(const ASessionId: string): TMVCWebSession;
{ webcontext events} { webcontext events}
procedure OnWebContextCreate(const WebContextCreateEvent: TWebContextCreateEvent); procedure OnWebContextCreate(const WebContextCreateEvent: TWebContextCreateEvent);
@ -1916,7 +1916,7 @@ begin
Result := (not UserName.IsEmpty) and (LoggedSince > 0); Result := (not UserName.IsEmpty) and (LoggedSince > 0);
end; end;
function TUser.LoadFromSession(const AWebSession: TWebSession): Boolean; function TUser.LoadFromSession(const AWebSession: TMVCWebSession): Boolean;
var var
SerObj: string; SerObj: string;
Pieces: TArray<string>; Pieces: TArray<string>;
@ -1940,7 +1940,7 @@ begin
end; end;
end; end;
procedure TUser.SaveToSession(const AWebSession: TWebSession); procedure TUser.SaveToSession(const AWebSession: TMVCWebSession);
var var
LRoles: string; LRoles: string;
begin begin
@ -1968,9 +1968,9 @@ end;
{ TWebContext } { TWebContext }
function TWebContext.AddSessionToTheSessionList(const ASessionType, ASessionId: string; function TWebContext.AddSessionToTheSessionList(const ASessionType, ASessionId: string;
const ASessionTimeout: Integer): TWebSession; const ASessionTimeout: Integer): TMVCWebSession;
var var
Session: TWebSession; Session: TMVCWebSession;
begin begin
if (Trim(ASessionType) = EmptyStr) then if (Trim(ASessionType) = EmptyStr) then
raise EMVCException.Create('Empty Session Type'); raise EMVCException.Create('Empty Session Type');
@ -2142,16 +2142,35 @@ begin
Result := FRequest.ParamsTable; Result := FRequest.ParamsTable;
end; end;
function TWebContext.GetWebSession: TWebSession; function TWebContext.GetWebSession: TMVCWebSession;
var
lSessionIDFromRequest: string;
lSessionType: String;
begin begin
if not Assigned(FWebSession) then if not Assigned(FWebSession) then
begin begin
FWebSession := TMVCEngine.GetCurrentSession( lSessionIDFromRequest := TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest);
TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest), False); FWebSession := TMVCEngine.GetCurrentSession(lSessionIDFromRequest, False);
if not Assigned(FWebSession) then if not Assigned(FWebSession) then
SessionStart begin
lSessionType := Config[TMVCConfigKey.SessionType];
if not TMVCSessionFactory.GetInstance.TryFindSessionID(lSessionType, lSessionIDFromRequest) then
begin
SessionStart(lSessionType);
end
else
begin
FWebSession := AddSessionToTheSessionList(
lSessionType,
lSessionIDFromRequest,
StrToInt(Config[TMVCConfigKey.SessionTimeout]));
TMVCEngine.SendSessionCookie(Self, FWebSession.SessionId);
end;
end
else else
begin
TMVCEngine.SendSessionCookie(Self, FWebSession.SessionId); TMVCEngine.SendSessionCookie(Self, FWebSession.SessionId);
end;
end; end;
Result := FWebSession; Result := FWebSession;
Result.MarkAsUsed; Result.MarkAsUsed;
@ -2179,14 +2198,14 @@ begin
Result := FSessionMustBeClose; Result := FSessionMustBeClose;
end; end;
procedure TWebContext.SessionStart; procedure TWebContext.SessionStart(const SessionType: String);
var var
ID: string; ID: string;
begin begin
if not Assigned(FWebSession) then if not Assigned(FWebSession) then
begin begin
ID := TMVCEngine.SendSessionCookie(Self); ID := TMVCEngine.SendSessionCookie(Self);
FWebSession := AddSessionToTheSessionList(Config[TMVCConfigKey.SessionType], ID, FWebSession := AddSessionToTheSessionList(SessionType, ID,
StrToInt64(Config[TMVCConfigKey.SessionTimeout])); StrToInt64(Config[TMVCConfigKey.SessionTimeout]));
FIsSessionStarted := True; FIsSessionStarted := True;
FSessionMustBeClose := False; FSessionMustBeClose := False;
@ -2229,10 +2248,20 @@ begin
begin begin
raise EMVCSessionExpiredException.Create('Session not started'); raise EMVCSessionExpiredException.Create('Session not started');
end; end;
GlobalSessionList.Remove(SId); GlobalSessionList.Remove(SId);
if SId <> '' then if SId <> '' then
begin begin
FWebSession := nil; FWebSession := nil;
try
TMVCSessionFactory.GetInstance.TryDeleteSessionID(Config[TMVCConfigKey.SessionType], SId);
except
on E: Exception do
begin
LogException(E, 'Cannot delete session file for sessionid: ' + SId);
end;
end;
end; end;
finally finally
TMonitor.Exit(GlobalSessionList); TMonitor.Exit(GlobalSessionList);
@ -3093,8 +3122,8 @@ begin
end; end;
end; end;
class function TMVCEngine.GetCurrentSession(const ASessionId: string; const ARaiseExceptionIfExpired: Boolean): TWebSession; class function TMVCEngine.GetCurrentSession(const ASessionId: string; const ARaiseExceptionIfExpired: Boolean): TMVCWebSession;
var lSessionList: TObjectDictionary<string, TWebSession>; var lSessionList: TObjectDictionary<string, TMVCWebSession>;
begin begin
Result := nil; Result := nil;
lSessionList := GlobalSessionList; lSessionList := GlobalSessionList;
@ -3128,7 +3157,7 @@ begin
end; end;
end; end;
function TMVCEngine.GetSessionBySessionId(const ASessionId: string): TWebSession; function TMVCEngine.GetSessionBySessionId(const ASessionId: string): TMVCWebSession;
begin begin
Result := TMVCEngine.GetCurrentSession(ASessionId, False); Result := TMVCEngine.GetCurrentSession(ASessionId, False);
if Assigned(Result) then if Assigned(Result) then
@ -3340,10 +3369,14 @@ begin
end; end;
class function TMVCEngine.SendSessionCookie(const AContext: TWebContext): string; class function TMVCEngine.SendSessionCookie(const AContext: TWebContext): string;
var SId: string; var
SId: string;
begin begin
SId := StringReplace(StringReplace(StringReplace('DT' + GUIDToString(TGUID.NewGuid), '}', '', []), SId := StringReplace(StringReplace(StringReplace(
'{', '', []), '-', '', [rfReplaceAll]); 'DT' + GUIDToString(TGUID.NewGuid) + GUIDToString(TGUID.NewGuid),
'}', '', [rfReplaceAll]),
'{', '', [rfReplaceAll]),
'-', '', [rfReplaceAll]);
Result := SendSessionCookie(AContext, SId); Result := SendSessionCookie(AContext, SId);
end; end;
@ -3621,7 +3654,7 @@ begin
Result := Context.Request.GetHeader('If-Match'); Result := Context.Request.GetHeader('If-Match');
end; end;
function TMVCController.GetSession: TWebSession; function TMVCController.GetSession: TMVCWebSession;
begin begin
Result := GetContext.Session; Result := GetContext.Session;
end; end;