正在显示
3 个修改的文件
包含
18 行增加
和
2 行删除
| @@ -102,4 +102,9 @@ public class MqttService { | @@ -102,4 +102,9 @@ public class MqttService { | ||
| 102 | } | 102 | } |
| 103 | return SysConfig.mqttConfig.subTopic; | 103 | return SysConfig.mqttConfig.subTopic; |
| 104 | } | 104 | } |
| 105 | + | ||
| 106 | + public boolean isConnect() | ||
| 107 | + { | ||
| 108 | + return mqttclient != null && mqttclient.isConnected(); | ||
| 109 | + } | ||
| 105 | } | 110 | } |
| @@ -29,7 +29,13 @@ public class Task { | @@ -29,7 +29,13 @@ public class Task { | ||
| 29 | data.put("playurl", playurl); | 29 | data.put("playurl", playurl); |
| 30 | data.put("online", oline); | 30 | data.put("online", oline); |
| 31 | jsonObject.put("1_1",data); | 31 | jsonObject.put("1_1",data); |
| 32 | - MqttService.getInstance().publish("ADD_POST", jsonObject.toJSONString()); | 32 | + MqttService mqttService = MqttService.getInstance(); |
| 33 | + if(mqttService.isConnect()) | ||
| 34 | + { | ||
| 35 | + mqttService.publish("ADD_POST", jsonObject.toJSONString()); | ||
| 36 | + }else{ | ||
| 37 | + mqttService.sart(); | ||
| 38 | + } | ||
| 33 | } catch (Exception e) { | 39 | } catch (Exception e) { |
| 34 | logger.error("定时任务执行异常", e); | 40 | logger.error("定时任务执行异常", e); |
| 35 | } | 41 | } |
| @@ -101,7 +101,12 @@ public class WebRtcService { | @@ -101,7 +101,12 @@ public class WebRtcService { | ||
| 101 | try (DatagramSocket socket = new DatagramSocket()) { | 101 | try (DatagramSocket socket = new DatagramSocket()) { |
| 102 | socket.connect(InetAddress.getByName("8.8.8.8"), 10002); | 102 | socket.connect(InetAddress.getByName("8.8.8.8"), 10002); |
| 103 | InetAddress localAddress = socket.getLocalAddress(); | 103 | InetAddress localAddress = socket.getLocalAddress(); |
| 104 | - return SysConfig.webrtc_host=localIp=localAddress.getHostAddress(); | 104 | + String ip = localAddress.getHostAddress(); |
| 105 | + if("0.0.0.0".equals(ip)) | ||
| 106 | + { | ||
| 107 | + return null; | ||
| 108 | + } | ||
| 109 | + return localIp=ip; | ||
| 105 | } | 110 | } |
| 106 | } catch (Exception e) { | 111 | } catch (Exception e) { |
| 107 | e.printStackTrace(); | 112 | e.printStackTrace(); |
-
请 注册 或 登录 后发表评论