| | |
| | | /** |
| | | * instance |
| | | */ |
| | | private volatile static HDLAuthSocket instance; |
| | | private static final HDLAuthSocket instance=new HDLAuthSocket(); |
| | | |
| | | private HDLAuthSocket() { |
| | | initListenerGatewayEvent(); |
| | |
| | | * |
| | | * @return HDLAuthSocket |
| | | */ |
| | | public static synchronized HDLAuthSocket getInstance() { |
| | | if (instance == null) { |
| | | synchronized (HDLLinkConfig.class) { |
| | | if (instance == null) { |
| | | instance = new HDLAuthSocket(); |
| | | } |
| | | } |
| | | } |
| | | public static HDLAuthSocket getInstance() { |
| | | // if (instance == null) { |
| | | // synchronized (HDLAuthSocket.class) { |
| | | // if (instance == null) { |
| | | // instance = new HDLAuthSocket(); |
| | | // } |
| | | // } |
| | | // } |
| | | return instance; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return 返回当前对象 |
| | | */ |
| | | private UdpSocketBoot getUdpBoot() { |
| | | private synchronized UdpSocketBoot getUdpBoot() { |
| | | try { |
| | | if (udpSocketBoot == null) { |
| | | udpSocketBoot = UdpClient.init(UDP_PORT, getUdpOptions()); |
| | | udpSocketBoot.bind(); |
| | | } |
| | | } catch (Exception e) { |
| | | // return null; |
| | | LogUtils.e("初始化Socket udp异常"+e.getMessage()); |
| | | } |
| | | |
| | | return udpSocketBoot; |
| | |
| | | //2.构建监听Listener |
| | | // authEvent = |
| | | //3.监听网关广播的入网指令 |
| | | EventDispatcher.getInstance().remove(TopicConstant.GATEWAY_AUTH_BROADCAST); |
| | | EventDispatcher.getInstance().register(TopicConstant.GATEWAY_AUTH_BROADCAST, new EventListener() { |
| | | @Override |
| | | public void onMessage(Object msg) { |
| | | LogUtils.i("收到网关认证信息: "); |
| | | NetworkAccessBroadcastResponse bean = getNetworkAccessBroadcastResponse(msg); |
| | | if (bean != null) { |
| | | //移除监听 |