73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
using Newtonsoft.Json;
|
|
using Server.SQL;
|
|
using static Server.Scheduler.SessionScheduler;
|
|
|
|
namespace Server.System
|
|
{
|
|
public abstract class AbstractService
|
|
{
|
|
public abstract Protocol ProtocolValue();
|
|
|
|
public abstract string Process();
|
|
|
|
public abstract Req Requst(string json);
|
|
|
|
public virtual bool Session(Req req)
|
|
{
|
|
if(req.uuid == "")
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 입력 요청 데이터
|
|
/// </summary>
|
|
public abstract class Req
|
|
{
|
|
public Protocol cmd;
|
|
|
|
public string uuid;
|
|
|
|
public User user;
|
|
public virtual bool IsReceivedAllField()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public virtual bool GetRedis()
|
|
{
|
|
try
|
|
{
|
|
Dictionary<string, object> hash = Statics.redis.GetAllHash("UserInfo", uuid);
|
|
user.id = (int)hash["id"];
|
|
user.uuid = (string)hash["uuid"];
|
|
user.mail = (string)hash["mail"];
|
|
user.nickname = (string)hash["nickname"];
|
|
user.gold = (int)hash["gold"];
|
|
user.free_cash = (int)hash["free_cash"];
|
|
user.pay_cash = (int)hash["pay_cash"];
|
|
Statics.redis.SetHash("end_login", DateTime.Now, "UserInfo", uuid);
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 반환 데이터
|
|
/// </summary>
|
|
public abstract class Resp
|
|
{
|
|
public int status = 200;
|
|
public virtual string ToJson()
|
|
{
|
|
return JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
}
|