【转】UniGUI Session管理說明

(2015-12-29 15:41:15)

  分类: uniGUI
台中cmj朋友在uniGUI中文社区QQ群里发布的,转贴至此。

UniGUI Session管理說明
每一個Session對應一個UniMainModule,一個MainForm
因此Session+UniMainModule就可以得到所有Session+使用者的資料
以做管理之用

[UniServerModule]
 
  Public區定義
    UserList:TList; //登入Session List

//事件
  procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
   begin
     UserList:=UniServerModule.SessionManager.Sessions.SessionList;
   end;
//---------------------------------------------------------------------------------
[UniMainModule]

Public //定義,由設計者自行決
    UserID:String;       //登入使用者ID
    LoginTime:TDateTime; //登入時間
    Msg:String;          //做Session間訊息傳遞

BrowserType:String;  //Session之瀏覽器類別
    BrowserVersion:integer; //Session之瀏覽器版本
    OSType:String;
    IsMobile:Boolean;    //Session是否Mobile

RType:Integer; //OnHandleRequest執行類別

//事件,此處可處理Session間的訊息
  //只要使用者在瀏覽器有動作,會觸發本事件
  //UniGUI的Session接受其他Session的訊息,無法主動顯示,
  procedure TUniMainModule.UniGUIMainModuleHandleRequest(ASession: TObject;var Handled: Boolean);
  var Session:TUniGUISession;
      MF:TMainForm;
   begin
     Session:=TUniGUISession(ASession);
     MF:=TMainForm( Session.UniMainModule.MainForm ); //Session對應的MainForm
     case Self.RType of
      1:begin
          MF.UniLabel1.Caption:='TEST訊息'; //
          Session.ShowAlert('OK');
        end;
      2:begin
        end;
      3:begin
        end;
     end;
     Self.RType:=-1; //
   end;
//---------------------------------------------------------------------------------
[LoginForm]

//事件,設定Session沒定義的資料
 procedure TLoginForm.BtnLoginClick(Sender: TObject);
 var ok:Boolean;
     C:TUniClientInfoRec; //uniGUIApplication.pas
     m:TuniMainModule;
  begin
    m:=UniMainModule; //
    //--處理可否登錄 Ok=True可登入
    m.UserID:=Self.EdUser.Text; //UserID在Session沒有,是自行加入
    C:=UniApplication.ClientInfoRec;
    m.SessionID:=UniSession.SessionID;
    m.LoginTime:=Now;

m.BrowserType:=C.BrowserType;
    m.BrowserVersion:=C.BrowserVersion;
    m.OSType:=C.OSType;
    m.IsMobile:=UniSession.IsMobile;

Ok:=True; //自行決定如此處理Ok
    //記錄登入使用者處理
    if Ok then
     begin
       ModalResult:=mrOK;  // Login is valid so proceed to MainForm ,執行段 Login form會Destory
     end;
  end;

//---------------------------------------------------------------------------------
[MainForm]

//事件,列出Session一覽表
 procedure TMainForm.UniButton7Click(Sender: TObject);
 var i:integer;
     Session:TUniGUISession;
     m:TUniMainModule; //Session對應的UniMainModule
  begin
    Self.PageControl.ActivePageIndex:=0;
    Self.MLog.Clear;
    for i:=0 to UniServerModule.UserList.Count-1 do
     begin
       Session:= TUniGUISession( UniServerModule.UserList[i]);
       m:=TUniMainModule(Session.UniMainModule);
       Self.MLog.Lines.Add( Session.SessionId +','+
                            m.UserID +','+
                            FormatDateTime('yyyy.mm.dd-hh:nn:ss.zzz',LoginTime:TDateTime; )+','+
                            m.BrowserType+','+
                            inttostr(m.BrowserVersion)+','+
                            m.OSType+','+
                            inttostr(ord(m.IsMobile))
                        );
     end;
  end;

【转】UniGUI Session管理說明的更多相关文章

  1. man page分類與說明

    轉載自http://itzone.hk/article/article.php?aid=200407152225014657 (如有侵權,請留言或來信告知) 前言 Man page是每位程式設計員及U ...

  2. Datasnap 服务端 (Server)Session 管理 --- 解决 全示例慢(Google)

    Datasnap 服务端 (Server)Session  管理:  http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Server_Side_Ses ...

  3. NUC970 U-Boot 使用說明

    U-Boot 使用說明U-Boot 是一個主要用於嵌入式系統的開機載入程式, 可以支援多種不同的計算機系統結構, 包括ARM.MIPS.x86與 68K. 這也是一套在GNU通用公共許可證之下發布的自 ...

  4. Nhibernate的Session管理

    参考:http://www.cnblogs.com/renrenqq/archive/2006/08/04/467688.html 但这个方法还不能解决Session缓存问题,由于创建Session需 ...

  5. Openfire的启动过程与session管理

    说明   本文源码基于Openfire4.0.2.   Openfire的启动       Openfire的启动过程非常的简单,通过一个入口初始化lib目录下的openfire.jar包,并启动一个 ...

  6. ABP(现代ASP.NET样板开发框架)系列之7、ABP Session管理

    点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之7.ABP Session管理 ABP是“ASP.NET Boilerplate Project (ASP.NET ...

  7. 2016-1-30 Servlet中Session管理(Sesssion追踪)

    Session管理(Sesssion追踪)是Web应用程序开发中非常重要的一个主题.这是因为HTTP是无状态的,在默认情况下,Web服务器不知道一个HTTP请求是来自初次用户,还是来自之前已经访问过的 ...

  8. Redis3.2+Tomcat实现集群的Session管理 -- tomcat-redis-session-manager的编译和开发部署环境搭建

    已经有不少文章介绍使用tomcat-redis-session-manager来实现Redis存储Tomcat的Session,实现分布式Session管理.但是现在官方编译的tomcat-redis ...

  9. tomcat架构分析 (Session管理)

    Session管理是JavaEE容器比较重要的一部分,在app中也经常会用到.在开发app时,我们只是获取一个session,然后向session中存取数据,然后再销毁session.那么如何产生se ...

随机推荐

  1. ARM 版本

    M  microcontroller 单片机 STM32                                M0 M0+   M3  M4  M7低功耗 A applicatioin 应用 ...

  2. 子页面调整父亲页面的iframe元素

    $('iframe', parent.document).attr('scrolling','no');

  3. Spring4新特性

    参考 : https://jinnianshilongnian.iteye.com/blog/1990081

  4. 438. Find All Anagrams in a String

    原题: 438. Find All Anagrams in a String 解题: 两个步骤 1)就是从s中逐步截取p长度的字符串 2)将截取出的字符串和p进行比较,比较可以用排序,或者字典比较(这 ...

  5. CentOS7下安装Gitlab社区版【安装步骤、IP改域名、修改端口】

    这两天一直在给公司的服务器配置Gitlab(10.5.4).过程很是痛苦,所以把过程记录一下. 1.安装CentOS7 从官网上下载了最新版CentOS-7-x86_64-DVD-1708.iso.用 ...

  6. php 获取数组深度的key

    1.数组 深度遍历 function fun($a,&$b) { foreach ($a as $k=>$val) { if (is_array($val)) { $b[]=$k; fu ...

  7. Tomcat-servlet基础

    1.1 概念 运行在服务器上的小程序   定义了浏览器访问到(tomact)的规则 1.2 步骤 1.3 执行原理 1  当服务器 接收到客户端浏览器的请求后  会解析url地址  获得url路径   ...

  8. body标签

    标签(空格分隔): body标签 body标签: 想要在网页上展示出来的内容一定要放在body标签中. 把我们之前那一段HTML代码贴过来,保存到一个HTML格式的文件中. <!DOCTYPE ...

  9. C++成员函数在内存中的存储方式

    用类去定义对象时,系统会为每一个对象分配存储空间.如果一个类包括了数据和函数,要分别为数据和函数的代码分配存储空间.按理说,如果用同一个类定义了10个对象,那么就需要分别为10个对象的数据和函数代码分 ...

  10. 通过启动函数定位main()函数

      如下,通过vc6.0编写一个hello world程序.尝试结合汇编代码.分析启动函数找到main函数.   在printf(xxx)插入断点,调试执行.如下,在堆栈窗口中可见main()下的一个 ...