设为首页 加入收藏

TOP

WebSocket使用示例(二)
2015-11-10 13:46:05 来源: 作者: 【 】 浏览:19
Tags:WebSocket 使用 示例
rn content;
? }
? return content.substring(0, content.lastIndexOf("&"));
?}
?
?/**
? * 获取发送人信息
? * @param content String
? * @return String
? */
?private String getToUserName(String content) {
? if (!AssertUtil.hasValue(content)) {
? ?return null;
? }
? if (!content.contains("&")) {
? ?return null;
? }
? return content.substring(content.lastIndexOf("&")+1, content.length());
?}
?
?/**
? * 链接打开之后将开发人员添加到回话池中
? * @param session
? */
?@OnOpen
?public void onOpen(Session session) {
? String poolId = this.getPoolId(session);
? if (AssertUtil.hasValue(poolId)) {
? ?WebChatPool.add(poolId, session.getId(), session);
? }
?}
?
?@OnClose
?public void onClose(Session session) {
? String poolId = this.getPoolId(session);
? if (AssertUtil.hasValue(poolId)) {
? ?WebChatPool.remvoe(poolId, session.getId());
? }
?}
?
?
?/**
? * 当前会话池ID
? * @param session
? * @return
? */
?private String getPoolId(Session session) {
? Map> paramMap = session.getRequestParameterMap();
? if (AssertUtil.hasValue(paramMap)) {
? ?List wx101IdList = paramMap.get("wx101id");
? ?if (AssertUtil.hasValue(wx101IdList)) {
? ? return wx101IdList.get(0);
? ?}
? }
? return null;
?}
}


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Spring+SpringMVC企业快速开发架.. 下一篇Python调用API接口的几种方式

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: