【转】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. android 开发 View _6_Canvas详解

    牛逼大神的博客地址:http://www.gcssloop.com/customview/Canvas_BasicGraphics 安卓自定义View进阶-Canvas之绘制图形 在上一篇自定义Vie ...

  2. 《算法导论》——顺序统计RandomizedSelect

    RandomizedSelect.h: #include <stdlib.h> namespace dksl { /* *交换 */ void Swap(int* numArray,int ...

  3. C#设计模式(2)——简单工厂模式(Factory )

    我们通过 Factory 创建对象不同的对象. 例如:如果创建一个汽车的接口,通过 工厂Factory 创建实现接口的对象,根据我们的选择来创建不同的对象. 创建汽车接口 /// <summar ...

  4. Android Jetpack 概述

    Android Jetpack Overview Android Jetpack Jetpack is a set of libraries, tools and architectural guid ...

  5. ABAP-FTP-配置

    1.FTP配置: 设置FTP参数:IP地址.账号.密码.路径.RFC目标. 设置数据表:数据表及字段明细,设置查询字段及报表输出字段. 2.操作界面 3.程序 ZFID0003_ETL_FTP 主程序 ...

  6. linux查看文件夹大小du命令

    查看1级(--max-depth=1)目录的大小,并排序 参考 -h或–human-readable 以K,M,G为单位,提高信息的可读性. –max-depth= 超过指定层数的目录后,予以忽略 d ...

  7. typedef typename

    所以根据上述两条分析,  typedef typename RefBase::weakref_type weakref_type; 语句的真是面目是: typedef创建了存在类型的别名,而typen ...

  8. html2canvas

    最近公司有个需求,实现html 页面元素转为png图像,这边用了html2canvas来实现.,这里记录一下,避免以后忘了~~ 官网链接: http://html2canvas.hertzen.com ...

  9. git配置正确且权限已开但是pull或push提示无权限

    因为之前提示输入用户名和密码时输入错误,之后就一直权限认证失败.这种情况下在git bash中输入: git config --system --unset credential.helper 就会重 ...

  10. 图片转base64上传,视频同理。

    body: <input type="file" id="img" type="file" onchange="up()&q ...