diff --git a/Server/Scheduler/SessionScheduler.cs b/Server/Scheduler/SessionScheduler.cs index 4b868f5..09577a5 100644 --- a/Server/Scheduler/SessionScheduler.cs +++ b/Server/Scheduler/SessionScheduler.cs @@ -1,6 +1,7 @@ using NLog; using Server.SQL; using Server.System; +using StackExchange.Redis; namespace Server.Scheduler { @@ -32,9 +33,9 @@ namespace Server.Scheduler logger.Info($"New User : {user.nickname}, session : {loginUUID}"); foreach (var item in users) { - if(item.Value == (object)(StackExchange.Redis.RedisValue)user.id) + if((RedisValue)item.Value == (RedisValue)user.id) { - Statics.redis.RemoveHash(item.Key); + Statics.redis.RemoveHash(item.Key, "LoginUsers"); Statics.redis.SetHash(loginUUID, user.id, "LoginUsers"); updateSession(loginUUID); return loginUUID; @@ -59,24 +60,28 @@ namespace Server.Scheduler //세션 업데이트 public static void updateSession(string UUID) { - int id = (int)Statics.redis.GetHash(UUID, "LoginUsers"); + ((RedisValue)Statics.redis.GetHash(UUID, "LoginUsers")).TryParse(out int id); Statics.redis.SetHash("end_login", DateTime.Now.ToString(), "UserInfo", id.ToString()); } public static User GetUser(string UUID) { User user = new User(); - int id = (int)Statics.redis.GetHash(UUID, "LoginUsers"); + + ((RedisValue)Statics.redis.GetHash(UUID, "LoginUsers")).TryParse(out int id); Dictionary userHash= Statics.redis.GetAllHash("UserInfo", id.ToString()); - - user.id = (int)userHash["id"]; - user.uuid = (string)userHash["uuid"]; - user.mail = (string)userHash["mail"]; - user.nickname = (string)userHash["nickname"]; - user.gold = (int)userHash["gold"]; - user.free_cash = (int)userHash["free_cash"]; - user.pay_cash = (int)userHash["pay_cash"]; + ((RedisValue)userHash["id"]).TryParse(out int user_id); + user.id = user_id; + user.uuid = userHash["uuid"].ToString().Trim('"'); + user.mail = userHash["mail"].ToString().Trim('"'); + user.nickname = userHash["nickname"].ToString().Trim('"'); + ((RedisValue)userHash["gold"]).TryParse(out int user_gold); + user.gold = user_gold; + ((RedisValue)userHash["free_cash"]).TryParse(out int user_free_cash); + user.free_cash = user_free_cash; + ((RedisValue)userHash["pay_cash"]).TryParse(out int user_pay_cash); + user.pay_cash = user_pay_cash; Statics.redis.SetHash("end_login", DateTime.Now.ToString(), "UserInfo", id.ToString()); return user; } diff --git a/Server/System/Abstract.cs b/Server/System/Abstract.cs index 95268a6..df63462 100644 --- a/Server/System/Abstract.cs +++ b/Server/System/Abstract.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using NLog; using Server.Scheduler; using Server.SQL; @@ -25,6 +26,7 @@ namespace Server.System /// public abstract class Req { + private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger(); public Protocol cmd; public string uuid;