package com.example.demo;

import com.example.demo.common.CacheMapRoot;
import com.example.demo.common.ExitListener;
import com.example.demo.common.GlobalConfig;
import com.example.demo.common.GlobalRoot;
import com.example.demo.module.iosapi.AppleUtil;
import com.example.demo.module.user.Player;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import pers.jc.engine.JCEngine;

/**
 * 入口启动类
 */
@SpringBootApplication
public class SmartBowBusinessServerApplication {

	public static void main(String[] args) {
		GlobalConfig.init();
		GlobalRoot.init();
		CacheMapRoot.init();
		ExitListener.init();
		SpringApplication.run(SmartBowBusinessServerApplication.class, args);
	}

	@EventListener
	public void deploymentVer(ApplicationReadyEvent event) {
		System.out.println("SpringBoot准备完毕！");
		if (GlobalConfig.serverConfig.getServerIndex() >= 0) {
			AppleUtil.initAppleInfo();
			new Thread(() -> {
				JCEngine.defaultAuthValue = true;
				JCEngine.scanPackage("com.example.demo.module");
				JCEngine.boot(11433, "/SmartBowBusinessServerSK2", Player.class);
			}).start();
		}
	}
}
