0.2.6 fix

1.bug修复
This commit is contained in:
jianguo 2024-05-27 16:31:25 +08:00
parent 667fa242d3
commit f0707c5412
3 changed files with 24 additions and 15 deletions

View File

@ -14,7 +14,7 @@ import javax.swing.*;
@Slf4j
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
public static void main(String[] args) {
log.info(" 当前系统类型: {}", SystemUtils.getOsName());
try {
//设置窗口主题

View File

@ -104,14 +104,21 @@ public class MainWindow extends JFrame {
}
public static void initSocket() {
SocketFactory.start();
if(SocketFactory.start()){
setView("socket 服务启动成功");
}else{
setView("socket 服务启动失败请检查8997端口是否被占用");
}
}
public void stopSocket() {
try {
SocketFactory.stop();
if(SocketFactory.stop()){
setView("服务停止成功");
}else{
setView("服务停止失败");
}
Thread.sleep(1000);
setView("服务关闭");
log.info("服务关闭");
} catch (InterruptedException e) {
throw new RuntimeException(e);

View File

@ -28,35 +28,37 @@ public class SocketFactory {
* 获取Socket客户端
* @return socketServer
*/
private static SocketServer getSocket(){
try {
log.info("Create Socket ...");
socketServer = new SocketServer(8997);
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
private static SocketServer getSocket() throws UnknownHostException {
log.info("Create Socket ...");
socketServer = new SocketServer(8997);
return socketServer;
}
/**
* 启动socket服务
*/
public static void start(){
getSocket().start();
public static boolean start() {
try {
getSocket().start();
} catch (UnknownHostException e) {
return false;
}
log.info("socket 已启动");
return true;
}
/**
* 停止socket服务
*/
public static void stop(){
public static boolean stop(){
try {
if(socketServer != null){
socketServer.stop();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
return false;
}
return true;
}
}