Skip to content

Commit

Permalink
feat: 修改Communication类以优化Socket处理
Browse files Browse the repository at this point in the history
  • Loading branch information
shulng committed Sep 7, 2024
1 parent 7d193a9 commit 980825c
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/main/java/cc/baka9/catseedlogin/bukkit/Communication.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,24 @@ private static void handleKeepLoggedInRequest(String playerName, String time, St
}
}

private static void handleConnectRequest(Socket socket, String playerName) {
CatScheduler.runTask(() -> {
boolean result = LoginPlayerHelper.isLogin(playerName);
CatSeedLogin.instance.runTaskAsync(() -> {
private static void handleConnectRequest(Socket socket, String playerName) {
CatScheduler.runTask(() -> {
boolean result = LoginPlayerHelper.isLogin(playerName);
CatSeedLogin.instance.runTaskAsync(() -> {
try {
socket.getOutputStream().write(result ? 1 : 0);
socket.getOutputStream().flush(); // 确保数据发送
} catch (IOException e) {
CatSeedLogin.instance.getLogger().warning("发送连接结果时发生错误: " + e.getMessage());
} finally {
try {
socket.getOutputStream().write(result ? 1 : 0);
socket.close();
} catch (IOException e) {
CatSeedLogin.instance.getLogger().warning("发送连接结果时发生错误: " + e.getMessage());
} finally {
try {
socket.close();
} catch (IOException e) {
CatSeedLogin.instance.getLogger().warning("关闭Socket时发生错误: " + e.getMessage());
}
CatSeedLogin.instance.getLogger().warning("关闭Socket时发生错误: " + e.getMessage());
}
});
}
});
}
});
}

}

0 comments on commit 980825c

Please sign in to comment.