| | |
| | | @OnOpen |
| | | public void onOpen(Session session, EndpointConfig config) { |
| | | this.session = session; |
| | | /*HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession"); |
| | | HttpSession httpSession = (HttpSession) config.getUserProperties().get("httpSession"); |
| | | UserInf user = (UserInf) httpSession.getAttribute("user"); |
| | | final int userId = user.getUid();*/ |
| | | final int userId = 10001; |
| | | final int userId = user.getUid(); |
| | | //final int userId = 10001; |
| | | |
| | | Thread thread = new Thread("Thread_HomeSocket") { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | |
| | | while (!currentThread().isInterrupted()) { |
| | | while (!currentThread().isInterrupted()) { |
| | | Map<String, Object> res = sendHome(userId); |
| | | session.getBasicRemote().sendObject(new Response().set(1, res)); |
| | | sleep(5000); |
| | | } |
| | | Map<String, Object> res = sendHome(userId); |
| | | session.getBasicRemote().sendObject(new Response().set(1, res)); |
| | | sleep(5000); |
| | | } |
| | | } catch (Exception e) { |
| | | this.interrupt(); |