/** 处理会话 */ @Override public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception { // TODO Auto-generated method stub Map<String, String> select = JsonUtil.jsonToMap(message.getPayload().toString()); String result = webSocketService.getNewMessage(select); session.sendMessage(new TextMessage(result.toString())); WebSocketCache.putMemberSession(select.get("userId"), session); }
/** 连接成功 */ @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { // TODO Auto-generated method stub System.out.println(session); Map<String, String> select = new HashMap<String, String>(); String userId = (String) session.getAttributes().get("userId"); String userPwd = (String) session.getAttributes().get("userPwd"); select.put("userId", userId); select.put("userPwd", userPwd); String result = webSocketService.getNewMessage(select); session.sendMessage(new TextMessage(result.toString())); WebSocketCache.putMemberSession(select.get("userId"), session); }