package com.zcloud.config;

import com.zcloud.plugins.websocketFace.FaceServer;
import org.java_websocket.WebSocketImpl;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 说明：web服务器启动后立即执行
 * 作者：luoxiaobao
 * 官网：www.qdkjchina.com
 */
@Component
@Order(value = 1) // 1 代表启动顺序
public class StartWebsocketServer implements ApplicationRunner{

	@Override
    public void run(ApplicationArguments var1) throws Exception{
        startWebsocketInstantFace();  //启动定时人脸识别服务
		System.out.println("-------------------系统启动成功-------------------");
    }

    /**
     * 启动定时人脸识别服务
     */
    public void startWebsocketInstantFace(){
        WebSocketImpl.DEBUG = false;
        FaceServer s;
        try {
            String imPort = "8899";					//即时通讯端口
            s = new FaceServer(Integer.parseInt(imPort));
            s.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
