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 ...
随机推荐
- java调用restful接口的方法
Restful接口的调用,前端一般使用ajax调用,后端可以使用的方法如下: 1.HttpURLConnection实现 2.HttpClient实现 3.Spring的RestTemplate
- 一款使用C# .NET开发的SIP网络电话客户端完整源码
一款使用C# .NET开发的SIP客户端开源项目.测试可编译通过运行,特此分享一下.可以对接ASTGO.VOS2009.VOS3000.NTS.UCS等各种SIP协议的软交换! 下载地址:https: ...
- 学学cookie和session
什么是Cookie? HTTP Cookie(也叫 Web Cookie或浏览器 Cookie)是服务器发送到用户浏览器并保存在本地的一小块数据,它会在浏览器下次向同一服务器发起请求时被携带并发送到服 ...
- 适用于zTree 、EasyUI tree、EasyUI treegrid
#region System.Text.StringBuilder b_appline = new System.Text.StringBuilder(); Syste ...
- Java经典算法之插入排序(Insert Sort)
插入排序在局部有序的情况下比冒泡排序快一倍,比选择排序快一点. 那什么是插入排序,就是将局部有序的数据向右移动,将未排序的数据插到他的前面 下面我们来解析代码: 这里外层循环out变量从1开始向右移动 ...
- centos7离线安装rabbitmq
准备工作 一台centos7的机器 erlang-21.3.8.2 RabbitMQ 3.7.15 socat-1.7.3.2-2.el7.x86_64.rpm 开始安装 登录centos ,把上面的 ...
- CyclibcBarrier与CountDownLatch区别
1.CyclibcBarrier的线程运行到某个位置后即停止运行,直到所有的线程都到达这个点,所有线程才开始运行:CountDownLatch是线程运行到某个点后,计数器-1,程序继续运行即Cycli ...
- Sorting It All Out 拓扑排序+确定点
这一道题的话 数据有一点问题 ........ 例如 不过 还是 能理解一下 试试吧 ......... A<B B<C C<A A<C B<A ...
- 【BZOJ2762】[JLOI2011]不等式组(树状数组)
题目: BZOJ2762 分析: 加入的不等式分三种情况 当\(a>0\),可以变成\(x>\lfloor \frac{c-b}{a}\rfloor\) 当\(a=0\),若\(b> ...
- ACM_Reverse Bits(反转二进制)
Reverse Bits Time Limit: 2000/1000ms (Java/Others) Problem Description: Reverse bits of a given 32 b ...