| | |
| | | * |
| | | * @param topic 发送数据 |
| | | * @param bodyStr 回复的主题 |
| | | * @param broadcast 是否要广播 |
| | | * @param callBack 回调 |
| | | */ |
| | | public void udpSendMsg(String topic, String bodyStr, HDLLinkResponseCallBack callBack) { |
| | | public void udpSendMsg(String topic, String bodyStr,boolean broadcast, HDLLinkResponseCallBack callBack) { |
| | | if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) { |
| | | if (callBack != null) { |
| | | callBack.onError(HDLLinkException.getErrorWithCode(HDLLinkCode.HDL_DATA_NULL_ERROR)); |
| | |
| | | |
| | | LinkRequest message = new LinkRequest(topic, bodyStr); |
| | | String ip = HDLLinkConfig.getInstance().getIpAddress(); |
| | | if(broadcast) { |
| | | ip = IpUtils.getBroadcastAddress(); |
| | | } |
| | | HdlSocketHelper.sendUdp(getUdpBoot(), ip, UDP_PORT, message, new HdlSocketHelper.HdlSocketListener() { |
| | | @Override |
| | | public void onSucceed(Object msg) { |
| | |
| | | * |
| | | * @param topic 发送数据 |
| | | * @param bodyStr 回复的主题 |
| | | * @param broadcast 是否广播 |
| | | */ |
| | | public void udpSendMsg(String topic, String bodyStr) { |
| | | public void udpSendMsg(String topic, String bodyStr,boolean broadcast) { |
| | | if (TextUtils.isEmpty(topic) || TextUtils.isEmpty(bodyStr)) { |
| | | LogUtils.e("udpSendMsg", "参数不能为空"); |
| | | return; |
| | |
| | | return; |
| | | } |
| | | LinkRequest message = new LinkRequest(topic, bodyStr); |
| | | String ip = HDLLinkConfig.getInstance().getIpAddress();// IpUtils.getBroadcastAddress(); |
| | | String ip = HDLLinkConfig.getInstance().getIpAddress(); |
| | | if(broadcast) { |
| | | ip = IpUtils.getBroadcastAddress(); |
| | | } |
| | | HdlSocketHelper.sendUdpOne(getUdpBoot(), ip, UDP_PORT, message); |
| | | } |
| | | |