Re: Getting all Session Objects From Application
Re: Getting all Session Objects From Application
- Subject: Re: Getting all Session Objects From Application
- From: Chuck Hill <email@hidden>
- Date: Wed, 23 Apr 2008 21:35:25 -0700
Hi Owen,
On Apr 23, 2008, at 9:15 PM, Owen McKerrow wrote:
Hi All,
I have an app that needs to display all of the people who are
currently logged in. Session has an instance of Person in it, which
represents who's logged into that session.
Now what I wanted to do was have a method in Application which
returned an array of the people it gathered from each of its sessions.
I think if you look in the archives, you will find a few threads on
this.
Now the thing I can't figure out is how to get an array of Sessions
from Application. I can ask the Application for its WOSessionStore,
but I can't seem to get a Session out of this without either a
Session ID or a WORequest.
File that under "preventing you from shooting yourself in the foot".
Is there anyway to do what Im after ?
Yes, but not how you are trying to do it.
Another approach would be to manually keep a "static" list of people
who have logged in inside Application, which is updated on Log-In
and again on Log Out or session.terminate(). But it would be quite
easy to get into a situation where this list gets out of sync ( say
if someone doesn't log out, and logs in again a second time, you may
end up with 2 of the person in the list, or just one, but it
disappears when their first session times out ). Anyways thats why I
wanted to go with a "dynamic" listing from Application itself.
I don't see how the dynamic list is going to be any different. If
someone logs in, and then logs in again without logging out, there are
still going to be two sessions. I'd consider a dictionary of session
ID to user name or User global ID (not the User object in the
session's editing context!). Making a set of all the objects will get
you the unique list of maybe logged in users (maybe because they may
have gone away without logging out). Have session tell the
application to add a user to the dictionary on login, and remove the
entry under the session ID when they log out or time out.
But if you have multiple instances, you probably really want to do
this in the database and then you have a whole new class of issues to
deal with.
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden