CTZLauncher/CTZLauncher/CTZAuth/CTZAuth.cs

50 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using CityCraft;
namespace CTZLauncher.CTZAuth
{
class CTZAuth : ICTZAuth
{
HttpHelper http = new HttpHelper();
string address;
int port;
CTZAuth(string address,int port = 25565)
{
this.address = address;
this.port = port;
}
public bool isRegister(string username)
{
return getResult(address + ":" + port + "/isregister?username=" + username);
}
public bool Register(string username, string password)
{
return getResult(address + ":" + port + "/register?username=" + username + "&password=" + password);
}
public bool isLogin(string username)
{
return getResult(address + ":" + port + "/islogin?username=" + username);
}
public bool Login(string username, string password)
{
return getResult(address + ":" + port + "/login?username=" + username + "&password=" + password);
}
public bool getResult(string url)
{
string result = http.Send(HttpMethod.GET, url);
if (result == "true")
return true;
return false;
}
}
}