hxb
2022-04-12 17b81245f31d032d5eed69c190e42edb1949f46b
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/socket/HDLAuthSocket.java
@@ -68,7 +68,7 @@
    /**
     * instance
     */
    private volatile static HDLAuthSocket instance;
    private  static final HDLAuthSocket instance=new HDLAuthSocket();
    private HDLAuthSocket() {
        initListenerGatewayEvent();
@@ -84,14 +84,14 @@
     *
     * @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;
    }
@@ -110,14 +110,14 @@
     *
     * @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;
@@ -136,9 +136,11 @@
        //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) {
                    //移除监听