UniGui中如何监听Session的开始与结束
来源:互联网 发布:淘宝的千里眼在线人数 编辑:程序博客网 时间:2024/05/22 14:30
UNIGui中的UniServerModule模块有一个SessionManager(TUNIGuiSessionManger类)的属性,通过 TUNIGuiSessionManger类的相关属性可以来监听web会话的开始与结束。
如:
UniServerModule.SessionManager.Sessions.OnSessionStart := OnSessionStart;UniServerModule.SessionManager.Sessions.OnSessionEnd := OnSessionEnd;procedure TFrmMon.OnSessionStart(Sender: TIdHTTPSession);var RemoteIp,SessionID:string;begin RemoteIP:= TUniGUISession(Sender).UniApplication.RemoteAddress; SessionID:= TUniGUISession(Sender).SessionID; //根据ip和会话编号进一步处理。end;procedure TFrmMon.OnSessionEnd(Sender: TIdHTTPSession);var RemoteIp,SessionID:string;begin RemoteIP:= TUniGUISession(Sender).UniApplication.RemoteAddress; SessionID:= TUniGUISession(Sender).SessionID; //根据ip和会话编号进一步处理。 end;
下面是一个完整的代码单元:
unit ServerModule;interfaceuses SysUtils, System.IOUtils,uniGUIServer, uniGUIMainModule, uniGUIApplication,UIdCustomHTTPServer,System.Classes;type TUniServerModule = class(TUniGUIServerModule) procedure UniGUIServerModuleCreate(Sender: TObject); private { Private declarations } procedure OnSessionStart(Sender: TIdHTTPSession); procedure OnSessionEnd(Sender: TIdHTTPSession); protected procedure FirstInit; override; public { Public declarations } end;function UniServerModule: TUniServerModule;implementation{$R *.dfm}uses UniGUIVars, Main;function UniServerModule: TUniServerModule;begin Result:=TUniServerModule(UniGUIServerInstance);end;procedure TUniServerModule.FirstInit;begin InitServerModule(Self);end;procedure TUniServerModule.OnSessionEnd(Sender: TIdHTTPSession);var ls :TStringList;begin // ls := TStringList.Create; if TFile.Exists(UniServerModule.StartPath+'sys.log') then begin ls.LoadFromFile(UniServerModule.StartPath+'sys.log'); end ; ls.Add('go exit'); ls.SaveToFile(UniServerModule.StartPath+'sys.log'); ls.Free;end;procedure TUniServerModule.OnSessionStart(Sender: TIdHTTPSession);var ls :TStringList;begin // ls := TStringList.Create; if TFile.Exists(UniServerModule.StartPath+'sys.log') then begin ls.LoadFromFile(UniServerModule.StartPath+'sys.log'); end ; ls.Add('go enter'); ls.SaveToFile(UniServerModule.StartPath+'sys.log'); ls.Free;end;procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);begin UniServerModule.SessionManager.Sessions.OnSessionStart := OnSessionStart; UniServerModule.SessionManager.Sessions.OnSessionEnd := OnSessionEnd;end;initialization RegisterServerModuleClass(TUniServerModule);end.
- UniGui中如何监听Session的开始与结束
- Listener的使用(监听用户session的开始和结束,HttpSession范围内属性的改变)
- 仿微信摇一摇实现摇动开始与结束监听
- UNIGUI中如果获得Session情况
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-X 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-x 程序是如何开始运行与结束的
- Cocos2d-X 程序是如何开始运行与结束的
- Widrow-Hoff算法的原始及对偶形式
- Linux设备驱动总结
- windows安装eaccelerator
- Http断点续传
- 【玩转无线网络 分享在win 7系统下无线网络的设置方法】
- UniGui中如何监听Session的开始与结束
- 登录linux,忘记root用户密码的操作步骤
- 什么是 WPS
- ntfs-3g的安装和配置
- 【win xp SP2系统秘密武器大曝光】
- Android:控件属性
- HDU4565(数学)
- Android应用添加(创建)和删除及判断是否存在桌面快捷方式
- 汇编指令大全(有注释)