From 79a53284b0acc93ad5795b8613103734fa308e2d Mon Sep 17 00:00:00 2001 From: j502647092 Date: Mon, 3 Aug 2015 20:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=96=E9=83=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E7=99=BB=E5=BD=95=E6=A8=A1=E5=9D=97...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Authentication/CTZAuthenticator.cs | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 CTZLauncher/Authentication/CTZAuthenticator.cs diff --git a/CTZLauncher/Authentication/CTZAuthenticator.cs b/CTZLauncher/Authentication/CTZAuthenticator.cs new file mode 100644 index 0000000..9c02b95 --- /dev/null +++ b/CTZLauncher/Authentication/CTZAuthenticator.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Threading; +using KMCCC.Authentication; +using CityCraft; +using System.Threading.Tasks; +using System.Threading; + +namespace KMCCC.Authentication +{ + class CTZAuthenticator + { + /// + /// 玩家的名字 + /// + public readonly string Username; + public readonly string Password; + HttpHelper http = new HttpHelper(); + /// + /// 验证服务器地址 + /// + public readonly string Address; + /// + /// 验证服务器端口 + /// + public readonly int Port; + /// + /// 构造离线验证器 + /// + /// 玩家的名字 + public CTZAuthenticator(string username, string password, string address, int port = 25565) + { + Username = username; + Password = password; + Address = address.IndexOf("http") > 0 ? address : "http://" + address; + Port = port; + } + + /// + /// 标注外部登陆验证器 + /// + public string Type + { + get { return "KMCCC.CTZ"; } + } + + public bool isRegistered() + { + return getResult(Address + ":" + Port + "/isregistered?username=" + Username); + } + + public bool Register() + { + return getResult(Address + ":" + Port + "/register?username=" + Username + "&password=" + Password); + } + + public bool isLogin() + { + return getResult(Address + ":" + Port + "/islogin?username=" + Username); + } + + public bool Login() + { + return getResult(Address + ":" + Port + "/login?username=" + Username + "&password=" + Password); + } + + public bool getResult(string url) + { + return http.Send(HttpMethod.GET, url) == "true" ? true : false; + } + } +}