/** * 文件名: ConnectionStore.java 2012-7-16 */ package com.gxzy.framework.comm.rtc.store; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.servlet.AsyncContext; import javax.servlet.http.HttpServletRequest; /** * 连接仓库 * @作者 AMY * @版本 1.0 */ public class ConnectionStore { private static final Map<String, List<AsyncContext>> store = new ConcurrentHashMap<String, List<AsyncContext>>(); //保存用户发送的最后一个rtc请求时间 private static final Map<String, Date> lastTtcStore = new ConcurrentHashMap<String, Date>(); public static Map<String, List<AsyncContext>> getStore() { return store; } /** * 孙雄伟改造支持多个链接 * 往仓库中放入一个新的连接,改造支持多个链接 * @param key * @param context */ public static void put(String key, AsyncContext context) { List<AsyncContext> acs = store.get(key); if(acs == null){ acs = new ArrayList<AsyncContext>(); store.put(key, acs); } acs.add(context); //store.put(key, acs); //store.put(key, context); //context.getRequest().gets System.out.println("request----------"+((HttpServletRequest)context.getRequest()).getSession().getId()); //org.apache.shiro.web.servlet.ShiroHttpServletRequest lastTtcStore.put(key, new Date()); } /** * 是否包含给定主键的连接 * @param key * @return */ public static boolean contain(String key) { return store.containsKey(key); } /** * 返回给定主键的连接,并且将连接从仓库中移除 * @param key * @return */ public static List<AsyncContext> poll(String key) { if(!store.containsKey(key)) return null; List<AsyncContext> context = store.get(key); store.remove(key); return context; } /** * 删除 * @param key */ public static void remove(String key) { if(store.containsKey(key)) store.remove(key); } }

li_li321 LV1
1月6日
dapeng0011 LV15
2024年8月25日
zgf099 LV1
2022年9月19日
hanweinan6 LV13
2022年9月16日
Jack261108 LV2
2022年5月6日
hnn0909 LV1
2022年4月2日
lyxtmy LV1
2022年1月27日
msssg123 LV1
2022年1月25日
ruiqiujuice LV1
2021年12月21日
密码烟雨城 LV1
2021年12月13日

新哥新奇士橙 LV4
1月26日
li_li321 LV1
1月6日
dearxo2014 LV1
2024年11月9日
dapeng0011 LV15
2024年8月25日
西瓜哥哥 LV4
2023年12月17日
诚壹lllyz
2023年11月17日
暂无贡献等级
溪若白 LV1
2023年7月13日
Dominick LV14
2023年6月19日
zzhua195 LV6
2023年5月29日
wuziayng1232 LV10
2023年2月21日