Redis 버그 수정
This commit is contained in:
parent
f90a1ae65a
commit
f60c5f60e8
|
|
@ -1,6 +1,7 @@
|
||||||
using NLog;
|
using NLog;
|
||||||
using Server.SQL;
|
using Server.SQL;
|
||||||
using Server.System;
|
using Server.System;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
namespace Server.Scheduler
|
namespace Server.Scheduler
|
||||||
{
|
{
|
||||||
|
|
@ -32,9 +33,9 @@ namespace Server.Scheduler
|
||||||
logger.Info($"New User : {user.nickname}, session : {loginUUID}");
|
logger.Info($"New User : {user.nickname}, session : {loginUUID}");
|
||||||
foreach (var item in users)
|
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");
|
Statics.redis.SetHash(loginUUID, user.id, "LoginUsers");
|
||||||
updateSession(loginUUID);
|
updateSession(loginUUID);
|
||||||
return loginUUID;
|
return loginUUID;
|
||||||
|
|
@ -59,24 +60,28 @@ namespace Server.Scheduler
|
||||||
//세션 업데이트
|
//세션 업데이트
|
||||||
public static void updateSession(string UUID)
|
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());
|
Statics.redis.SetHash("end_login", DateTime.Now.ToString(), "UserInfo", id.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User GetUser(string UUID)
|
public static User GetUser(string UUID)
|
||||||
{
|
{
|
||||||
User user = new User();
|
User user = new User();
|
||||||
int id = (int)Statics.redis.GetHash(UUID, "LoginUsers");
|
|
||||||
|
((RedisValue)Statics.redis.GetHash(UUID, "LoginUsers")).TryParse(out int id);
|
||||||
Dictionary<string, object> userHash= Statics.redis.GetAllHash("UserInfo", id.ToString());
|
Dictionary<string, object> userHash= Statics.redis.GetAllHash("UserInfo", id.ToString());
|
||||||
|
|
||||||
|
((RedisValue)userHash["id"]).TryParse(out int user_id);
|
||||||
user.id = (int)userHash["id"];
|
user.id = user_id;
|
||||||
user.uuid = (string)userHash["uuid"];
|
user.uuid = userHash["uuid"].ToString().Trim('"');
|
||||||
user.mail = (string)userHash["mail"];
|
user.mail = userHash["mail"].ToString().Trim('"');
|
||||||
user.nickname = (string)userHash["nickname"];
|
user.nickname = userHash["nickname"].ToString().Trim('"');
|
||||||
user.gold = (int)userHash["gold"];
|
((RedisValue)userHash["gold"]).TryParse(out int user_gold);
|
||||||
user.free_cash = (int)userHash["free_cash"];
|
user.gold = user_gold;
|
||||||
user.pay_cash = (int)userHash["pay_cash"];
|
((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());
|
Statics.redis.SetHash("end_login", DateTime.Now.ToString(), "UserInfo", id.ToString());
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NLog;
|
||||||
using Server.Scheduler;
|
using Server.Scheduler;
|
||||||
using Server.SQL;
|
using Server.SQL;
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@ namespace Server.System
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Req
|
public abstract class Req
|
||||||
{
|
{
|
||||||
|
private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger();
|
||||||
public Protocol cmd;
|
public Protocol cmd;
|
||||||
|
|
||||||
public string uuid;
|
public string uuid;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue