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 ...
随机推荐
- Tiny4412 开发板 编译环境搭建【转】
本文转载自:http://blog.csdn.net/beijiwei/article/details/51055369 版权声明:本文为博主原创文章,未经博主允许不得转载. /*********** ...
- How to: Specify the Web Server for Web Projects in Visual Studio
https://msdn.microsoft.com/en-us/library/ms178108(v=vs.120).aspx When you run a Web project in Visua ...
- 第二周 Leetcode 493. Reverse Pairs(HARD)
leetcode 493跟经典的逆序对问题没有什么区别, 首先考虑对数组前半部和后半部求逆序对数,若能保证两段数组都有序,则显然可以在线性时间内求出对数. 所以我们采用归并排序的方法,一方面让数组有序 ...
- bzoj2752
线段树+概率 今天这道题爆零了,奥妙重重. 其实我们可以把式子化成这样:sigma((i-l+1)*(r-i+1)*ai) 这里r减了1 然后展开,(1-l)*(r+1)*ai+(r+l)*i*ai- ...
- opensStack
- astgo-完整功能介绍
核心功能: Astgo最核心和强大的功能是呼叫中心模块.接入方式:中继卡.模拟卡接入,中继网关.O口网关接入.网络IP接入等.单机200个坐席,通话实时录音.灵活队列分组.开放式IVR设计,修改业务逻 ...
- [Swift通天遁地]四、网络和线程-(2)通过BlockOperation实现线程的队列
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- 非常无聊——STD::sort VS 基数排序
众所周知,Std::sort()是一个非常快速的排序算法,它基于快排,但又有所修改.一般来说用它就挺快的了,代码一行,时间复杂度O(nlogn)(难道不是大叫一声“老子要排序!!”就排好了么...). ...
- ACM_蛋糕小王子铁头娃
Problem Description: 铁头娃制作了很多蛋糕,想分给他的小伙伴们,他的小伙伴很喜欢铁头娃做的蛋糕,每个人都想分到最多蛋糕 铁头娃想到了一个头铁主意:先给小伙伴们从1到N编号,在1-N ...
- webHttpBinding+wsHttpBinding+basicHttpBinding的区别 (转)
1. webHttpBinding (web AJAX/JSON)2. wsHttpBinding (ASP.NET client) 3. basicHttpBinding (Silverlight) ...