| | |
| | | } |
| | | } |
| | | |
| | | public String sendMessage(String message) throws Exception{ |
| | | // public String sendMessage(String message) throws Exception{ |
| | | // Map<String,Object> map = new HashMap<>(); |
| | | // |
| | | // // 获取当前日期和时间 |
| | | // LocalDateTime nowDateTime = LocalDateTime.now(); |
| | | // DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // System.out.println(dateTimeFormatter.format(nowDateTime)); |
| | | // map.put("server_time",dateTimeFormatter.format(nowDateTime)); |
| | | // map.put("server_code","200"); |
| | | // |
| | | // map.put("server_message",message); |
| | | // JSONObject jsonObject = new JSONObject(map); |
| | | // WebSocketServer.sendAllMessage(jsonObject.toString()); |
| | | // return jsonObject.toString(); |
| | | // } |
| | | |
| | | public String sendMessage(String message,String userid) throws Exception{ |
| | | Map<String,Object> map = new HashMap<>(); |
| | | |
| | | // 获取当前日期和时间 |
| | |
| | | |
| | | map.put("server_message",message); |
| | | JSONObject jsonObject = new JSONObject(map); |
| | | WebSocketServer.sendAllMessage(jsonObject.toString()); |
| | | WebSocketServer.sendInfo(jsonObject.toString(),userid); |
| | | return jsonObject.toString(); |
| | | } |
| | | } |