로컬 redis수정
This commit is contained in:
parent
2cf512d48b
commit
7064839819
|
|
@ -1,4 +1,3 @@
|
|||
using Server.Scheduler;
|
||||
using Server.System;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
using Server.SQL;
|
||||
using NLog;
|
||||
using Server.SQL;
|
||||
using Server.System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server.Scheduler
|
||||
{
|
||||
|
||||
public class SessionScheduler : System.Scheduler
|
||||
{
|
||||
public override void Process()
|
||||
|
|
@ -21,22 +22,22 @@ namespace Server.Scheduler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger();
|
||||
//신규 로그인
|
||||
public static void addSession(User user)
|
||||
public static string addSession(User user)
|
||||
{
|
||||
//기존 세션 확인
|
||||
string loginUUID = Guid.NewGuid().ToString();
|
||||
Dictionary<string, string> users = Statics.redis.GetAllHash("LoginUsers");
|
||||
|
||||
foreach(var item in users)
|
||||
logger.Info($"New User : {user.nickname}, session : {loginUUID}");
|
||||
foreach (var item in users)
|
||||
{
|
||||
if(int.Parse(item.Value) == user.id)
|
||||
{
|
||||
Statics.redis.RemoveHash(item.Key);
|
||||
Statics.redis.SetHash(loginUUID, user.id.ToString(), "LoginUsers");
|
||||
updateSession(loginUUID);
|
||||
return;
|
||||
return loginUUID;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,6 +52,8 @@ namespace Server.Scheduler
|
|||
userInfo.Add("pay_cash", user.pay_cash.ToString());
|
||||
userInfo.Add("end_login", DateTime.Now.ToString());
|
||||
Statics.redis.SetHash(userInfo, "UserInfo", user.id.ToString());
|
||||
|
||||
return loginUUID;
|
||||
}
|
||||
|
||||
//세션 업데이트
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Server.Service
|
|||
deckInfoList = Statics.deckInfoSQL.SelectUid(user.id);
|
||||
itemManager = new ItemManager(user);
|
||||
}
|
||||
if(user == null)
|
||||
if (user == null)
|
||||
{
|
||||
if (req.mail == "")
|
||||
{
|
||||
|
|
@ -78,7 +78,7 @@ namespace Server.Service
|
|||
#region 신규 덱 추가
|
||||
DeckInfo deckInfo;
|
||||
deckInfo = new DeckInfo();
|
||||
deckInfo.user_id= user.id;
|
||||
deckInfo.user_id = user.id;
|
||||
deckInfo.deck_type = 1;
|
||||
deckInfo.deck_unit0_id = itemManager.box.deckUnitInfo[0].id;
|
||||
deckInfo.deck_unit1_id = itemManager.box.deckUnitInfo[1].id;
|
||||
|
|
@ -96,11 +96,8 @@ namespace Server.Service
|
|||
}
|
||||
|
||||
//세션 추가
|
||||
addSession(user);
|
||||
string session = addSession(user);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 상점 세팅
|
||||
//리셋 상점
|
||||
List<ResetShopItem> resetShopItem = Statics.resetShopItemSQL.SelectUid(user.id);
|
||||
|
|
@ -112,10 +109,10 @@ namespace Server.Service
|
|||
//일일 상품 추가
|
||||
if (shopItemData == null)
|
||||
shopItemData = Statics.resetShopItemExcel.getResetShopItemData();
|
||||
List < ResetShopItemData > shopList = new List<ResetShopItemData>();
|
||||
foreach(var item in shopItemData)
|
||||
List<ResetShopItemData> shopList = new List<ResetShopItemData>();
|
||||
foreach (var item in shopItemData)
|
||||
{
|
||||
if(item.shop_index == 10001)
|
||||
if (item.shop_index == 10001)
|
||||
{
|
||||
shopList.Add(item);
|
||||
}
|
||||
|
|
@ -247,7 +244,7 @@ namespace Server.Service
|
|||
}
|
||||
}
|
||||
}
|
||||
if(addItem.Count != 0)
|
||||
if (addItem.Count != 0)
|
||||
{
|
||||
Statics.resetShopItemSQL.Insert(addItem);
|
||||
Statics.resetShopItemSQL.SaveChanges();
|
||||
|
|
@ -257,7 +254,7 @@ namespace Server.Service
|
|||
List<ShopItem> shopItem = Statics.shopItemSQL.SelectUid(user.id);
|
||||
#endregion
|
||||
|
||||
return makeResp(user, dynamicDataList, deckInfoList, itemManager, newUser, resetShopItem, shopItem);
|
||||
return makeResp(user, session, dynamicDataList, deckInfoList, itemManager, newUser, resetShopItem, shopItem);
|
||||
}
|
||||
|
||||
public override Protocol ProtocolValue() => Protocol.Login;
|
||||
|
|
@ -268,11 +265,12 @@ namespace Server.Service
|
|||
return req;
|
||||
}
|
||||
|
||||
private string makeResp(User user, List<DynamicData> dynamicData, List<DeckInfo> deckInfo, ItemManager itemManager, bool newUser, List<ResetShopItem> resetShopItem, List<ShopItem> shopItem)
|
||||
private string makeResp(User user, string session, List<DynamicData> dynamicData, List<DeckInfo> deckInfo, ItemManager itemManager, bool newUser, List<ResetShopItem> resetShopItem, List<ShopItem> shopItem)
|
||||
{
|
||||
LoginResp resp = new LoginResp();
|
||||
resp.nickname = user.nickname;
|
||||
resp.uuid = user.uuid;
|
||||
resp.session = session;
|
||||
resp.gold = (ulong)user.gold;
|
||||
resp.cash = (ulong)(user.free_cash + user.pay_cash);
|
||||
resp.new_user = newUser;
|
||||
|
|
@ -296,7 +294,7 @@ namespace Server.Service
|
|||
public string mail;
|
||||
public override bool IsReceivedAllField()
|
||||
{
|
||||
if(mail == null && uuid == null)
|
||||
if (mail == null && uuid == null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -309,6 +307,7 @@ namespace Server.Service
|
|||
public class LoginResp : Resp
|
||||
{
|
||||
public string uuid;
|
||||
public string session;
|
||||
public string nickname;
|
||||
public ulong gold;
|
||||
public ulong cash;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Server.System
|
|||
{
|
||||
if (password.Equals(string.Empty))
|
||||
{
|
||||
Console.WriteLine("true");
|
||||
Console.WriteLine("false");
|
||||
redis = ConnectionMultiplexer.Connect($"{host}:{port}");
|
||||
this.db = redis.GetDatabase(db);
|
||||
}
|
||||
|
|
@ -204,8 +204,6 @@ namespace Server.System
|
|||
if (local)
|
||||
{
|
||||
if (hashType.ContainsKey(KeySet(keys)))
|
||||
hashType.Add(KeySet(keys), new Dictionary<string, string> { { field, JsonConvert.SerializeObject(value) } });
|
||||
else
|
||||
{
|
||||
Dictionary<string, string> userHash = hashType[KeySet(keys)];
|
||||
if (userHash.ContainsKey(field))
|
||||
|
|
@ -213,6 +211,8 @@ namespace Server.System
|
|||
else
|
||||
userHash[field] = value;
|
||||
}
|
||||
else
|
||||
hashType.Add(KeySet(keys), new Dictionary<string, string> { { field, value } });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -231,11 +231,23 @@ namespace Server.System
|
|||
Dictionary<string, string> hash = new Dictionary<string, string>();
|
||||
if (local)
|
||||
{
|
||||
Dictionary<string, string> hashs = new Dictionary<string, string>(hashType[KeySet(keys)]);
|
||||
Dictionary<string, string> hashs;
|
||||
if (hashType.ContainsKey(KeySet(keys)))
|
||||
{
|
||||
hashs = hashType[KeySet(keys)];
|
||||
foreach (var entry in hashs)
|
||||
hash.Add(entry.Key, entry.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
hashs = new Dictionary<string, string>();
|
||||
foreach (var entry in hashs)
|
||||
hash.Add(entry.Key, entry.Value);
|
||||
hashType.Add(KeySet(keys), hashs);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
HashEntry[] hashEntries = db.HashGetAll(KeySet(keys));
|
||||
foreach (var entry in hashEntries)
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ namespace Server.System
|
|||
public static readonly string SQL_URL = "Host=192.168.1.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;";
|
||||
public static readonly string EXCEL_SQL_URL = "Host=192.168.1.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;";
|
||||
public static readonly string remoteUrl = "https://manager:BQNl01bJJF0wn9R@gitea.pandoli365.com/Team.thewar/thewar_excel.git";
|
||||
public static readonly Redis redis = new Redis("192.168.1.2", 6379, 1, "xPEz3x08xQ8G1Fa");
|
||||
public static readonly Redis redis = new Redis("localhost", 6379, 1, "xPEz3x08xQ8G1Fa");
|
||||
#elif LIVE
|
||||
public static readonly string SQL_URL = "Host=192.168.1.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;";
|
||||
public static readonly string EXCEL_SQL_URL = "Host=192.168.1.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;";
|
||||
public static readonly string remoteUrl = "https://manager:BQNl01bJJF0wn9R@gitea.pandoli365.com/Team.thewar/thewar_excel_live.git";
|
||||
public static readonly string remoteUrl = "https://manager:BQNl01bJJF0wn9R@gitea.pandoli365.com/Team.thewar/thewar_excel.git";
|
||||
public static readonly Redis redis = new Redis("192.168.1.2", 6379, 1, "xPEz3x08xQ8G1Fa");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue