在线统计人数_不同房间的统计人数


public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain)
throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
HttpSession session = request.getSession();
Long lastTime = new Date().getTime();
Long updateTime = (Long)session.getAttribute("updateTime");
String liveState = (String)request.getParameter("action");
int flag = 0;
String enlive = "";
String exlive = "";
String mobile = "";
Long liveroomid = 0l;
Long roomId = 0l;
String servletPath = request.getServletPath();
String islive = (String)session.getAttribute("islive");
if (IeachConstants.IEACE_ONLINE_PEOPLES_SERVLETPATH.indexOf(servletPath) != -1)
{
if (null != islive && !"".equals(islive))
{
flag = Integer.parseInt(islive);
}
if ("goLiveRoom".equals(liveState))
{
UserInfo userInfo = (UserInfo)session.getAttribute("userInfo");
if (flag == 0)
{
if (null != userInfo)
{

roomId = Parmfiltrate.toLong(request, "roomid");
updateTime = new Date().getTime();
session.setAttribute("updateTime", updateTime);
session.setAttribute("islive", "1");

OnlineSum.entryLive(session.getId(),
roomId,
userInfo.getMobile());

}

}

}
else
{

if (flag == 1)
{

OnlineSum.exitLive(session.getId());

session.setAttribute("islive", 0);

}

}
}
if (null != updateTime && lastTime >= updateTime
|| enlive.length() > 3000)
{
int sum =
OnlineSum.getenSessionUser().size()
+ OnlineSum.getexSessionUser().size();
if (sum >= 1)
{
for (Map.Entry<String, Long> entry : OnlineSum.getenSessionUser()
.entrySet())
{
liveroomid =
((Long)OnlineSum.getenSessionUser()
.get((String)entry.getKey()));
if (!OnlineSum.getexSessionUser()
.containsKey(entry.getKey()))
{
mobile =
OnlineSum.getSessionUser()
.get((String)entry.getKey());
enlive +=
liveroomid + ":" + (String)entry.getKey() + ":"
+ mobile + ",";
}

}
for (Map.Entry<String, Long> exit : OnlineSum.getexSessionUser()
.entrySet())
{
if (!OnlineSum.getenSessionUser()
.containsKey(exit.getKey()))
{
exlive += "'" + (String)exit.getKey() + "'" + ",";
}

}
if (exlive.length() > 0)
{
exlive = exlive.substring(0, exlive.length() - 1);
}
if (enlive.length() > 0)
{
enlive = enlive.substring(0, enlive.length() - 1);
}

}

liveOnlineService.getOnlineProcedure(enlive, exlive);

// 初始化用户session
OnlineSum.init();
session.setAttribute("updateTime",
new Date().getTime() + 5 * 60 * 1000);

}
chain.doFilter(request, response);

}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值