| | |
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通用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());
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 发送指令
|