【转】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. nginx+python+windows 开始

    参考文章:http://www.testwo.com/article/311 参考如上文章基本能够完成hello world示例,我来记录下自己操作步骤及不同点,用以备忘,如果能帮助到其他人更好. 以 ...

  2. html常用代码合集

    <!>字体效果 <h1>...</h1>标题字(最大) <h6>...</h6>标题字(最小) <b>...</b> ...

  3. Could not find a package,configuration file provided by "G2O" ,G2OConfig.cmake,g2o-config.cmake

    因为项目需要使用到g2o,所以自己从git上面clone下来, git clone https://github.com/RainerKuemmerle/g2o.git 然后: cd g2o mkdi ...

  4. jQuery——检测滚动条是否到达底部

    一.jQuery检测浏览器window滚动条到达底部 jQuery获取位置和尺寸相关函数:$(document).height()    获取整个页面的高度:$(window).height()    ...

  5. HBase Snapshot原理和实现

    HBase 从0.95开始引入了Snapshot,可以对table进行Snapshot,也可以Restore到Snapshot.Snapshot可以在线做,也可以离线做.Snapshot的实现不涉及到 ...

  6. Android 二维码扫描/生成

    先看看实现效果 1.在module的build.gradle中执行compile操作 compile 'cn.yipianfengye.android:zxing-library:2.2' 2.在Ap ...

  7. FortiGate防火墙500D下PC至外网丢包

    1.现状: 如图,防火墙堆叠,500D共4个出口方向,联通.电信.FQ.运维专线 2.现象: 到网关和防火墙上.下联口不丢包,到网联通和运维专线方向丢包4%左右,电信和FQ方向不丢包 3.分析 采用从 ...

  8. 【c++】内存检查工具Valgrind介绍,安装及使用以及内存泄漏的常见原因

    转自:https://www.cnblogs.com/LyndonYoung/articles/5320277.html Valgrind是运行在Linux上一套基于仿真技术的程序调试和分析工具,它包 ...

  9. Sass入门及知识点整理

    Sass 快速入门 | SASS 中文网 文档链接:https://www.sasscss.com/getting-started/ 前言 之前整理了一篇关于Less的,现在就来整理一下关于Sass的 ...

  10. Django实现支付宝支付

    一 去支付宝申请 - 正式:营业执照 - 测试: 沙箱测试环境    APPID:2016092000554391    买家: esnrce2727@sandbox.com    登录和支付密码: ...