mirror of
https://e.coding.net/circlecloud/CTZLoginServer.git
synced 2024-11-16 01:08:49 +00:00
fix some bug...
This commit is contained in:
parent
5bc4bd4bb2
commit
3a6f330500
@ -39,7 +39,7 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
// 等待请求,此方法会一直阻塞,直到获得请求才往下走
|
||||
while (true) {
|
||||
socket = s.accept();
|
||||
System.out.println("CTZL服务器收到请求 客户端IP: " + socket.getRemoteSocketAddress() + " 端口:"
|
||||
System.out.println("CTZL服务器收到请求 客户端IP: " + socket.getInetAddress() + " 端口:"
|
||||
+ socket.getPort());
|
||||
new ClientThread(socket).start();
|
||||
}
|
||||
@ -81,36 +81,42 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
String password = "";
|
||||
if (req.isSuccess) {
|
||||
switch (req.getPrefix().substring(1)) {
|
||||
case "isregister":
|
||||
username = req.getQuerystring("username");
|
||||
case "isregistered":
|
||||
username = req.Query("username");
|
||||
if (username == null) {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
"§6玩家: §a" + username + " §6请求注册检测!");
|
||||
if (API.isRegistered(username))
|
||||
res.setHtml("true");
|
||||
else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "register":
|
||||
username = req.getQuerystring("username");
|
||||
password = req.getQuerystring("password");
|
||||
username = req.Query("username");
|
||||
password = req.Query("password");
|
||||
if (username == null || password == null) {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
"§6玩家: §a" + username + " §6请求注册!");
|
||||
if (API.registerPlayer(username, password))
|
||||
res.setHtml("true");
|
||||
else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "login":
|
||||
username = req.getQuerystring("username");
|
||||
password = req.getQuerystring("password");
|
||||
username = req.Query("username");
|
||||
password = req.Query("password");
|
||||
if (username == null || password == null) {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
"§6玩家: §a" + username + " §6请求登录!");
|
||||
if (API.checkPassword(username, password))
|
||||
res.setHtml("true");
|
||||
// TODO 处理玩家后续登录事件
|
||||
@ -118,19 +124,21 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "islogin":
|
||||
username = req.getQuerystring("username");
|
||||
username = req.Query("username");
|
||||
if (username == null) {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(
|
||||
"§6玩家: §a" + username + " §6请求登录检测!");
|
||||
if (Bukkit.getPlayer(username) != null)
|
||||
res.setHtml("true");
|
||||
else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "changepassword":
|
||||
username = req.getQuerystring("username");
|
||||
password = req.getQuerystring("password");
|
||||
username = req.Query("username");
|
||||
password = req.Query("password");
|
||||
if (username == null) {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
@ -144,7 +152,6 @@ public class CTZLoginServerSocket implements Runnable {
|
||||
default:
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
}
|
||||
System.out.println(res.toString());
|
||||
pw.write(res.toString());
|
||||
pw.flush();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Request {
|
||||
// 解析URL
|
||||
prefix = args[1].substring(0, lastc);
|
||||
// 解析查询字符串
|
||||
String[] params = args[1].substring(lastc).split("&");
|
||||
String[] params = args[1].substring(lastc + 1).split("&");
|
||||
for (String param : params) {
|
||||
if (param.contains("=")) {
|
||||
String[] paraminfo = param.split("=");
|
||||
@ -79,7 +79,7 @@ public class Request {
|
||||
/**
|
||||
* @return 查询数据
|
||||
*/
|
||||
public String getQuerystring(String key) {
|
||||
public String Query(String key) {
|
||||
return querystring.get(key);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user