I am new to web design. So, can anybody tell me how to get information about all opened sessions? ( I am writing a game and i need to know abou开发者_开发技巧t all clients which are on-line at the moment ) I am using spring Mvc 3.0
Thanks for answers.
Sorry once more) i am dealing with my session like this:
request.getSession(true).setAttribute("client",client);
request.getSession(true).setAttribute(Constants.SESS_AUTH, Boolean.TRUE);
my listener is
@Override
public void sessionCreated(HttpSessionEvent arg0) {
totalActiveSessions++;
System.out.println("sessionCreated - add one client into list");
setOnline(arg0);
}
@Override
public void sessionDestroyed(HttpSessionEvent arg0) {
totalActiveSessions--;
System.out.println("sessionDestroyed - deduct one client from list");
setOffline(arg0);
}
private void setOnline(HttpSessionEvent sessionEvent){
HttpSession session = sessionEvent.getSession();
ApplicationContext ctx =
WebApplicationContextUtils.
getWebApplicationContext(session.getServletContext());
SessionService sessionService = (SessionService) ctx.getBean("sessionService");
sessionService.setClientOnLine((Client)sessionEvent.getSession().getAttribute("client"));
}
private void setOffline(HttpSessionEvent sessionEvent){
HttpSession session = sessionEvent.getSession();
ApplicationContext ctx =
WebApplicationContextUtils.
getWebApplicationContext(session.getServletContext());
SessionService sessionService = (SessionService) ctx.getBean("sessionService");
sessionService.setClientOffLine((Client)sessionEvent.getSession().getAttribute("client"));
}
unfortunately it doesnt works like i want... could you recommend something
精彩评论