-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hi all,
i am using a chat application and different users could be online at the same time and also i want to show the online people who are in chat now.. I think to put all users names or id's at a same session attribute..
How can i define a global session attribute or another way ??
Could it be ok for you to simply declare a static member variable inside a class?
Something like this:
public class SharedVariables { public static Map m_mUsers = new HashMap(); public static synchronized void addLoggedinUser(String sUser) { m_mUsers.put(sUsers, new Date()); } public static synchronized void removeLoggedinUser(String sUser) { m_mUsers.remove(sUsers); } }
Of course, you have to synchronize the map.
Asked: 2008-11-19 13:51:51 +0800
Seen: 145 times
Last updated: Nov 19 '08