package kr.co.compcarecompany.Util.Service;

import android.util.Log;

import org.eclipse.paho.client.mqttv3.MqttException;

import kr.co.compcarecompany.MyApplication;

public class TerminateThread extends Thread {
    private boolean isRun = true;
    private static int SLEEP = 6000;

    public TerminateThread() {
    }

    public void stopForever() {
        synchronized (this) {
            this.isRun = false;
        }
    }

    public void run() {

        while (isRun) {

//            try {
//                Thread.sleep(SLEEP);
//
//                if(MyApplication.mqttAndroidClient != null && MyApplication.mqttAndroidClient.isConnected()){
//                    Log.d("mqtt 종료@@@", "ㅇㅇㅇ");
//                    MyApplication.mqttAndroidClient.unregisterResources();
//                    MyApplication.mqttAndroidClient.close();
//                    MyApplication.mqttAndroidClient.disconnect();
//                    MyApplication.mqttAndroidClient.setCallback(null);
//                    MyApplication.mqttAndroidClient = null;
//                }
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//                break;
//            }
        }

        interrupt();
    }
}
