package net.northking.cctp.upperComputer.thread;

import net.northking.cctp.upperComputer.deviceManager.AndroidDeviceManager;
import net.northking.cctp.upperComputer.deviceManager.UpperComputerManager;
import net.northking.cctp.upperComputer.deviceManager.IOSDeviceManager;
import net.northking.cctp.upperComputer.service.DeviceConnectionService;
import net.northking.cctp.upperComputer.utils.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ShutdownHook extends Thread{

    private Logger logger = LoggerFactory.getLogger(ShutdownHook.class);

    @Override
    public void run() {

        logger.warn("关闭上位机程序.................");
        UpperComputerManager.shutdown();

        logger.warn("关闭ios设备管理程序.................");
        IOSDeviceManager.getInstance().shutdown();

        logger.warn("关闭android设备管理程序.................");
        AndroidDeviceManager.getInstance().shutdown();

        logger.warn("关闭连接中的设备与上位机连接.................");
        DeviceConnectionService connectionService = SpringUtils.getBean(DeviceConnectionService.class);
        connectionService.closeConnectedDevice();

    }
}
