| | |
| | | public void onMessage(Object msg) { |
| | | NetworkAccessBroadcastResponse bean = getNetworkAccessBroadcastResponse(msg); |
| | | if (bean != null) { |
| | | LogUtils.i(TAG, "网关入网广播IP: " + bean.getIPAddress()); |
| | | //移除监听 |
| | | EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); |
| | | LogUtils.i("网关入网广播IP: " + bean.getIPAddress()); |
| | | String ipStr = bean.getIPAddress(); |
| | | if (!TextUtils.isEmpty(ipStr)) { |
| | | sendAuthenticateRequest(ipStr, request, callBack); |
| | | } |
| | | } |
| | | //移除监听 |
| | | EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); |
| | | LogUtils.i(TAG, "移除监听 authEvent"); |
| | | |
| | | } |
| | | }); |
| | | } |
| | |
| | | * |
| | | * @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); |
| | | } |
| | | |