unigui的session【1】
目前是1394。
明白session如何使用管理,看demo Session List和SessionTimeout
unit Main; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniButton,
DB, DBClient, uniBasicGrid, uniDBGrid; type
TUniSessionInfoRec = record
ASessionId : string;
AIP : string;
AMyVar : string;
ALastTime: TDateTime;
end; TMainForm = class(TUniForm)
UniButton1: TUniButton;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
ClientDataSet1SessionId: TStringField;
ClientDataSet1IP: TStringField;
ClientDataSet1LastTime: TDateTimeField;
UniDBGrid1: TUniDBGrid;
ClientDataSet1MyVar: TStringField;
procedure UniButton1Click(Sender: TObject);
procedure UniFormCreate(Sender: TObject); { Private declarations }
public
{ Public declarations }
ASessionList : array of TUniSessionInfoRec;
end; function MainForm: TMainForm; implementation {$R *.dfm} uses
uniGUIVars, MainModule, uniGUIApplication, uniGUISessionManager,
ServerModule; function MainForm: TMainForm;
begin
Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end; procedure TMainForm.UniButton1Click(Sender: TObject);
var
S : TUniGUISessions;
U : TUniGUISession;
I : Integer;
begin
S := UniServerModule.SessionManager.Sessions;
S.Lock; // Using Lock on session manager should be used with extreme care.
// We should keep the "Lock duration" as short as we can. Session Manager stops working until lock is released.
// Excessive use of lock/unlock or keeping the lock active for a long period will make uniGUI server slow/unresponsive.
try
SetLength(ASessionList, S.SessionList.Count); // Here we do a fast copy of list to another array for later use.
for I := to S.SessionList.Count - do
begin
U := S.SessionList[I];
ASessionList[I].ASessionId := U.SessionId;
ASessionList[I].AIP := U.RemoteIP;
ASessionList[I].ALastTime := U.LastTimeStamp;
if U.UniMainModule <> nil then // Check mainModule availability. Some sessions may not have a MainModule instance
ASessionList[I].AMyVar := (U.UniMainModule as TUniMainModule).FMyStringVar; // Access custom MainModule props
end;
finally
S.Unlock; // ... and finally don't forget to release lock!
end; ClientDataSet1.EmptyDataSet;
for I := Low(ASessionList) to High(ASessionList) do
begin
ClientDataSet1.Append;
ClientDataSet1.FieldByName('sessionid').AsString := ASessionList[I].ASessionId;
ClientDataSet1.FieldByName('ip').AsString := ASessionList[I].AIP;
ClientDataSet1.FieldByName('lasttime').AsDateTime := ASessionList[I].ALastTime;
ClientDataSet1.FieldByName('myvar').AsString := ASessionList[I].AMyVar;
ClientDataSet1.Post;
end; end; procedure TMainForm.UniFormCreate(Sender: TObject);
begin
UniMainModule.FMyStringVar := TimeToStr(Now);
end; initialization
RegisterAppFormClass(TMainForm); end.
注意代码中的注释
unigui的session【1】的更多相关文章
- 记录一段QQ关于 UNIGUI 的Session 时间设定
记录一段QQ关于 UNIGUI 的Session 时间设定,来自[台中]cmj(31365722): [重點說明] 1.UniGUI的Session就是UniMainModule. 2.Sess ...
- 【转】UniGUI Session管理說明
[转]UniGUI Session管理說明 (2015-12-29 15:41:15) 转载▼ 分类: uniGUI 台中cmj朋友在uniGUI中文社区QQ群里发布的,转贴至此. UniGUI ...
- unigui session超时时间设置
unigui session超时时间设置 默认的SESSION超时时间是10分钟. 网络 SOCKET 程序,像 数据库,中间件,UNIGUI等...为了防止过多的僵死连接卡死服务端,服务端都会主动踢 ...
- UNIGUI:How to redirect and close session?
Hello, i would have 2 unigui app. the first app is a simple authentification app and second will be ...
- unigui数据库连接池
UNIGUI for delphi,是一款WEB RIA开发框架.开发WEB程式如传统C/S般简单,众多DELPHIER趋之若鹜. 虽然上手非常容易,但要真正使用好,有些地方还是值得考究的. 网上有同 ...
- Datasnap 服务端 (Server)Session 管理 --- 解决 全示例慢(Google)
Datasnap 服务端 (Server)Session 管理: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Server_Side_Ses ...
- unigui日志
unigui日志 uniGUI本身提供了日志功能,利用uniServerModule.ServerLogger来控制如何写日志: Enabled:是否写日志 Options:logIndyExcept ...
- uniGUI日志的控制
uniGUI日志的控制 (2015-10-12 08:30:29) 转载▼ 标签: unigui 分类: uniGUI uniGUI本身提供了日志功能,利用uniServerModule.Server ...
- unigui如何连接数据库
unigui如何连接数据库 UNIGUI既可以二层直连数据库,也可以通过中间件连接数据库. 这里只介绍UNIGUI二层直连数据库. 数据库连接控件.数据集控件都要拖放在MainModule窗体上.UN ...
随机推荐
- How to create a random UUID in each Request's Headers
${=java.util.UUID.randomUUID()} is OK
- Ubuntu下FileZilla的安装(转载)
转自:http://os.51cto.com/art/201103/247564.htm FileZilla是一个免费而且开源的FTP客户端软件,共有两种版本:客户端版本.服务器版本.FileZill ...
- E20170626-gg
occupy vt. 占领; 使用,住在…; 使从事,使忙碌; 任职; stack n. 垛,干草堆; (一排) 烟囱; 层积; 整个的藏书架排列;
- jquery插件开发基本步骤
一.介绍 插件编写的目的是给已经有的一系列方法或函数做一个封装,以便在其他地方重复使用,方便后期维护. JQuery除了提供一个简单.有效的方式进行管理元素以及脚本,它还还提供了例外一种机制:即给核心 ...
- 利用hexo来配合nginx来打造属于自己的纯静态博客系统
什么是静态网站生成器?顾名思义,就是以最快的速度生成一个高可用的web页面,我们知道Django作为一款非常流行的框架被广泛应用,但是部署起来实在是太麻烦了,各种命令各种配置,动态页面必然要涉及数据库 ...
- Linux下MySql数据的导入导出
1,每天4点备份mysql数据: 2,为节省空间,删除超过3个月的所有备份数据: 3,删除超过7天的备份数据,保留3个月里的 10号 20号 30号的备份数据: mysqldump -u用戶名 -p密 ...
- web.xml里,classpath使用范围
比如说在web.xml里,配置spring监听. 在标签<param-value>里,classpath指向的配置文件路径应该是在config资源文件夹下的applicationConte ...
- Flume OG 与 Flume NG 的对比
Flume OG 与 Flume NG 的对比 1.Flume OG Flume OG:Flume original generation 即Flume 0.9.x版本,它由agent.collect ...
- [转] 64位Oracle 11g R2的客户端连接时报ORA-01019错误
本文转自:http://blog.csdn.net/downmoon/article/details/8038583 在Win8企业版64位环境下,连接Oracle11g 服务端,搞了整整两天,特将过 ...
- MVC系列学习(九)-DTO的使用
本次学习用的数据库,如下 1.什么是DTO:DataTransferObject 即数据传输对象,服务端的客户端的通信,自动定义个小的实体类,里面只包含我们需要传输的属性 2.不用DTO会有什么问题 ...