bpromas
bpromas

Reputation: 694

Getting a session from its data

I have a session for the main thread in my application, and that session has valuable data inside it that I want to access. Usually I simply get the session using the TDSSessionManager.GetThreadSession method, but right now I'm having to access this session when outside of the main thread.

I thought of maybe getting my session by somehow referencing some of the data inside it, but I have no idea how. Is there any way for getting a session from something else than the thread you're in?

Upvotes: 2

Views: 425

Answers (2)

r_j
r_j

Reputation: 1368

You can loop through your Sessions, using the TDSSessionManager.Instance

TDSSessionManager.Instance.ForEachSession
  (
    procedure(const Session: TDSSession)
    begin
      if Session.HasData('User') then begin
        Listbox1.AddItem(Session.GetData('User'),Session);
      end;
    end
  );

Upvotes: 0

menjaraz
menjaraz

Reputation: 7575

Assuming your are using recent Delphi version, you can use Rtti to have a reference to it. TDSSessionManager implements singleton and that will facilitate your job.

Upvotes: 2

Related Questions