| | |
| | | */ |
| | | @OnMessage |
| | | public void onMessage(String message, Session session) throws Exception { |
| | | logger.info("用户消息:" + boxId + ",客户端:" + clientId + ",报文:" + message); |
| | | //logger.info("用户消息:" + boxId + ",客户端:" + clientId + ",报文:" + message); |
| | | //可以群发消息 |
| | | //消息保存到数据库、redis |
| | | if (StringUtil.isEmpty(message)) { |
| | |
| | | * 实现服务器主动推送 |
| | | */ |
| | | public void sendMessage(String message) throws IOException { |
| | | this.session.getBasicRemote().sendText(message); |
| | | //this.session.getBasicRemote().sendText(message); |
| | | synchronized (this.session) { |
| | | this.session.getBasicRemote().sendText(message); |
| | | } |
| | | } |
| | | |
| | | |