package com.ruoyi.netty;
|
|
|
import com.ruoyi.common.utils.netty.IPUtil;
|
import com.ruoyi.netty.communication.TcpServer;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationRunner;
|
import org.springframework.core.annotation.Order;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* @author 86175
|
*/
|
@Component
|
@Order(1)
|
@Slf4j
|
|
public class InitService implements ApplicationRunner {
|
|
|
@Override
|
public void run(ApplicationArguments args) {
|
log.info("---------------正在初始化程序请稍后------------------");
|
startTCPServer();
|
}
|
|
/**
|
* 启动TCP服务
|
*/
|
private void startTCPServer() {
|
String iP = IPUtil.getLocalIP();
|
Integer port = 6001;
|
log.info("端口为:" + port + "IP地址:" + iP);
|
try {
|
new TcpServer().init(iP, port);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
}
|