JLChen
2021-12-10 739d5bad0d24c5f4913f8d8e09292b5b98991fac
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLSocket.java
@@ -166,7 +166,10 @@
        pipeLine.add(new LinkMessageDecoder());
        pipeLine.add(new LinkMessageEncoder());
        options.setHandleMessage(pipeLine);
        options.setEnabledHeartbeat(false);
        options.setEnabledHeartbeat(false);//是否开启心跳包发送检测
//        options.setHeartbeatTimeInterval(10*1000L);
//        options.setHeartbeatData("TCP");
//        options.setEnabledHeartbeat(true);//是否开启心跳包发送检测
        return options;
    }
@@ -682,6 +685,24 @@
        }
    }
    /**
     * 通用TCP发送指令 只发一次,不监听回复,不重发
     *
     * @param topic    发送数据
     * @param bodyStr  回复的主题
     */
    public void tcpSendMsg(String topic, String bodyStr) {
        try {
            if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) {
                LogUtils.e("udpSendMsg", "参数不能为空");
                return;
            }
            LinkRequest message = new LinkRequest(topic, bodyStr);
            getTcp().sendMsg(message.getSendBytes());
        } catch (Exception e) {
            LogUtils.e("tcpSendMsg", "发送失败 :"+e.getMessage());
        }
    }
    /**
     * 发送指令