How to close the old session-if the same username starts a new session?

Source: Internet
Author: User

Question:

Want to close the old session-if the same username starts a new session

Any ideas how I can do this? -One user shoshould not be able to start the software unlimited in his company-every user shoshould 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;
 

How to close the old session-if the same username starts a new session?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.