| | |
| | | * udp默认端口 |
| | | */ |
| | | private static final int UDP_PORT = 8585; |
| | | private static int BIND_UDP_PORT = 8584; |
| | | /** |
| | | * 因为考虑到使用一个端口,要支持接收多网关的数据,所以只允许使用一个 |
| | | */ |
| | |
| | | private synchronized UdpSocketBoot getUdpBoot() { |
| | | try { |
| | | if (udpSocketBoot == null) { |
| | | udpSocketBoot = UdpClient.init(UDP_PORT, getUdpOptions()); |
| | | //区分是8584还是8585 |
| | | BIND_UDP_PORT = HDLSdk.getInstance().getBindPort(); |
| | | udpSocketBoot = UdpClient.init(BIND_UDP_PORT, getUdpOptions()); |
| | | udpSocketBoot.bind(); |
| | | |
| | | LogUtils.i("初始化Socket udp"); |
| | |
| | | if (broadcast) { |
| | | ip = IpUtils.getBroadcastAddress(); |
| | | } |
| | | HdlSocketHelper.sendUdp(getUdpBoot(), ip, UDP_PORT, message,"", 1, new HdlSocketHelper.HdlSocketListener() { |
| | | HdlSocketHelper.sendUdp(getUdpBoot(), ip, UDP_PORT, message, "", 1, new HdlSocketHelper.HdlSocketListener() { |
| | | @Override |
| | | public void onSucceed(Object msg) { |
| | | if (callBack == null) return; |
| | |
| | | HDLLinkConfig.getInstance().setCurrentGateway(searchBean);//设置当前网关 |
| | | if (mSearchGatewayCallBack != null) { |
| | | mSearchGatewayCallBack.onSuccess(searchBean); |
| | | HDLSocket.getInstance().isBroadcast = true; |
| | | HDLSocket.getInstance().getTcp(); |
| | | } |
| | | } |
| | | } |