zoukankan      html  css  js  c++  java
  • how to close the old Session

    Question:

     want to close the old Session - if the same username starts a new Session

    Any ideas how i can do this? - one user should not be able to start the Software unlimited in his company - every user should buy a licence .

    Answer:

    var
      ASessionList: TList;
      I : Integer;
      M : TUniMainModule;
      USession : TUniGUISession;
    begin
      ASessionList := UniServerModule.SessionManager.Sessions.SessionList.LockList;
      try
        for I := 0 to ASessionList.Count -1 do
        begin
          USession := TUniGUISession(ASessionList[i]);
          M := USession.UniMainModule as TUniMainModule;
          if M.username = 'ThisUserName' then
          begin
            USession.TerminateAfterSecs(0);
            Break;
          end;
        end;
      finally
        UniServerModule.SessionManager.Sessions.SessionList.UnlockList;
      end;
    end;

    Question:
     If I want to send a message to another session of the same user before I kill it,how do I do?
    Answer:
    begin USession := TUniGUISession(ASessionList[i]);
      M := USession.UniMainModule as TUniMainModule;
      if M.username = 'ThisUserName' then
      begin
       M.LMessageStr := 'Your Session will Terminate after 10 Sec !!!';////// <---
       USession.TerminateAfterSecs(10); Break;
       end;
    end;
    
    // And in the MainForm. a Timer With this code:
    procedure TMainFrm.UniTimer1Timer(Sender: TObject);
    begin
     if UniMainModule.LMessageStr <> '' then
     begin
      ShowMessage(UniMainModule.LMessageStr);
      UniMainModule.LMessageStr := '';
     end;
    end;
     
  • 相关阅读:
    Java乔晓松oracle的多表查询
    定义一个地址固定的变量
    J2ME的表单元素及其事件
    J2me的异常处理和多线程
    [置顶] eclipse远程部署,静态文件实时同步插件
    newlisp debugger
    启用isqlplus
    ORA27101: shared memory realm does not exist
    windows下安装node.js及less
    em启动/关闭报错解决
  • 原文地址:https://www.cnblogs.com/wxb-km/p/4051456.html
Copyright © 2011-2022 走看看