로컬 redis수정
This commit is contained in:
parent
2cf512d48b
commit
7064839819
|
|
@ -1,4 +1,3 @@
|
||||||
using Server.Scheduler;
|
|
||||||
using Server.System;
|
using Server.System;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using Server.SQL;
|
using NLog;
|
||||||
|
using Server.SQL;
|
||||||
using Server.System;
|
using Server.System;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace Server.Scheduler
|
namespace Server.Scheduler
|
||||||
{
|
{
|
||||||
|
|
||||||
public class SessionScheduler : System.Scheduler
|
public class SessionScheduler : System.Scheduler
|
||||||
{
|
{
|
||||||
public override void Process()
|
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();
|
string loginUUID = Guid.NewGuid().ToString();
|
||||||
Dictionary<string, string> users = Statics.redis.GetAllHash("LoginUsers");
|
Dictionary<string, string> users = Statics.redis.GetAllHash("LoginUsers");
|
||||||
|
logger.Info($"New User : {user.nickname}, session : {loginUUID}");
|
||||||
foreach(var item in users)
|
foreach (var item in users)
|
||||||
{
|
{
|
||||||
if(int.Parse(item.Value) == user.id)
|
if(int.Parse(item.Value) == user.id)
|
||||||
{
|
{
|
||||||
Statics.redis.RemoveHash(item.Key);
|
Statics.redis.RemoveHash(item.Key);
|
||||||
Statics.redis.SetHash(loginUUID, user.id.ToString(), "LoginUsers");
|
Statics.redis.SetHash(loginUUID, user.id.ToString(), "LoginUsers");
|
||||||
updateSession(loginUUID);
|
updateSession(loginUUID);
|
||||||
return;
|
return loginUUID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,6 +52,8 @@ namespace Server.Scheduler
|
||||||
userInfo.Add("pay_cash", user.pay_cash.ToString());
|
userInfo.Add("pay_cash", user.pay_cash.ToString());
|
||||||
userInfo.Add("end_login", DateTime.Now.ToString());
|
userInfo.Add("end_login", DateTime.Now.ToString());
|
||||||
Statics.redis.SetHash(userInfo, "UserInfo", user.id.ToString());
|
Statics.redis.SetHash(userInfo, "UserInfo", user.id.ToString());
|
||||||
|
|
||||||
|
return loginUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
//세션 업데이트
|
//세션 업데이트
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Server.Service
|
||||||
deckInfoList = Statics.deckInfoSQL.SelectUid(user.id);
|
deckInfoList = Statics.deckInfoSQL.SelectUid(user.id);
|
||||||
itemManager = new ItemManager(user);
|
itemManager = new ItemManager(user);
|
||||||
}
|
}
|
||||||
if(user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
if (req.mail == "")
|
if (req.mail == "")
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +78,7 @@ namespace Server.Service
|
||||||
#region 신규 덱 추가
|
#region 신규 덱 추가
|
||||||
DeckInfo deckInfo;
|
DeckInfo deckInfo;
|
||||||
deckInfo = new DeckInfo();
|
deckInfo = new DeckInfo();
|
||||||
deckInfo.user_id= user.id;
|
deckInfo.user_id = user.id;
|
||||||
deckInfo.deck_type = 1;
|
deckInfo.deck_type = 1;
|
||||||
deckInfo.deck_unit0_id = itemManager.box.deckUnitInfo[0].id;
|
deckInfo.deck_unit0_id = itemManager.box.deckUnitInfo[0].id;
|
||||||
deckInfo.deck_unit1_id = itemManager.box.deckUnitInfo[1].id;
|
deckInfo.deck_unit1_id = itemManager.box.deckUnitInfo[1].id;
|
||||||
|
|
@ -96,11 +96,8 @@ namespace Server.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
//세션 추가
|
//세션 추가
|
||||||
addSession(user);
|
string session = addSession(user);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 상점 세팅
|
#region 상점 세팅
|
||||||
//리셋 상점
|
//리셋 상점
|
||||||
List<ResetShopItem> resetShopItem = Statics.resetShopItemSQL.SelectUid(user.id);
|
List<ResetShopItem> resetShopItem = Statics.resetShopItemSQL.SelectUid(user.id);
|
||||||
|
|
@ -112,10 +109,10 @@ namespace Server.Service
|
||||||
//일일 상품 추가
|
//일일 상품 추가
|
||||||
if (shopItemData == null)
|
if (shopItemData == null)
|
||||||
shopItemData = Statics.resetShopItemExcel.getResetShopItemData();
|
shopItemData = Statics.resetShopItemExcel.getResetShopItemData();
|
||||||
List < ResetShopItemData > shopList = new List<ResetShopItemData>();
|
List<ResetShopItemData> shopList = new List<ResetShopItemData>();
|
||||||
foreach(var item in shopItemData)
|
foreach (var item in shopItemData)
|
||||||
{
|
{
|
||||||
if(item.shop_index == 10001)
|
if (item.shop_index == 10001)
|
||||||
{
|
{
|
||||||
shopList.Add(item);
|
shopList.Add(item);
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +124,7 @@ namespace Server.Service
|
||||||
{
|
{
|
||||||
int select = rand.Next(0, shopList.Count);
|
int select = rand.Next(0, shopList.Count);
|
||||||
int index = addItem.FindIndex(data => data.reset_shop_item_data_id == shopList[select].index);
|
int index = addItem.FindIndex(data => data.reset_shop_item_data_id == shopList[select].index);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
addItem[index].count++;
|
addItem[index].count++;
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +244,7 @@ namespace Server.Service
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(addItem.Count != 0)
|
if (addItem.Count != 0)
|
||||||
{
|
{
|
||||||
Statics.resetShopItemSQL.Insert(addItem);
|
Statics.resetShopItemSQL.Insert(addItem);
|
||||||
Statics.resetShopItemSQL.SaveChanges();
|
Statics.resetShopItemSQL.SaveChanges();
|
||||||
|
|
@ -257,22 +254,23 @@ namespace Server.Service
|
||||||
List<ShopItem> shopItem = Statics.shopItemSQL.SelectUid(user.id);
|
List<ShopItem> shopItem = Statics.shopItemSQL.SelectUid(user.id);
|
||||||
#endregion
|
#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;
|
public override Protocol ProtocolValue() => Protocol.Login;
|
||||||
|
|
||||||
public override Req Requst(string json)
|
public override Req Requst(string json)
|
||||||
{
|
{
|
||||||
req = JsonConvert.DeserializeObject<LoginReq>(json);
|
req = JsonConvert.DeserializeObject<LoginReq>(json);
|
||||||
return req;
|
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();
|
LoginResp resp = new LoginResp();
|
||||||
resp.nickname = user.nickname;
|
resp.nickname = user.nickname;
|
||||||
resp.uuid = user.uuid;
|
resp.uuid = user.uuid;
|
||||||
|
resp.session = session;
|
||||||
resp.gold = (ulong)user.gold;
|
resp.gold = (ulong)user.gold;
|
||||||
resp.cash = (ulong)(user.free_cash + user.pay_cash);
|
resp.cash = (ulong)(user.free_cash + user.pay_cash);
|
||||||
resp.new_user = newUser;
|
resp.new_user = newUser;
|
||||||
|
|
@ -296,7 +294,7 @@ namespace Server.Service
|
||||||
public string mail;
|
public string mail;
|
||||||
public override bool IsReceivedAllField()
|
public override bool IsReceivedAllField()
|
||||||
{
|
{
|
||||||
if(mail == null && uuid == null)
|
if (mail == null && uuid == null)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -309,6 +307,7 @@ namespace Server.Service
|
||||||
public class LoginResp : Resp
|
public class LoginResp : Resp
|
||||||
{
|
{
|
||||||
public string uuid;
|
public string uuid;
|
||||||
|
public string session;
|
||||||
public string nickname;
|
public string nickname;
|
||||||
public ulong gold;
|
public ulong gold;
|
||||||
public ulong cash;
|
public ulong cash;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace Server.System
|
||||||
{
|
{
|
||||||
if (password.Equals(string.Empty))
|
if (password.Equals(string.Empty))
|
||||||
{
|
{
|
||||||
Console.WriteLine("true");
|
Console.WriteLine("false");
|
||||||
redis = ConnectionMultiplexer.Connect($"{host}:{port}");
|
redis = ConnectionMultiplexer.Connect($"{host}:{port}");
|
||||||
this.db = redis.GetDatabase(db);
|
this.db = redis.GetDatabase(db);
|
||||||
}
|
}
|
||||||
|
|
@ -204,8 +204,6 @@ namespace Server.System
|
||||||
if (local)
|
if (local)
|
||||||
{
|
{
|
||||||
if (hashType.ContainsKey(KeySet(keys)))
|
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)];
|
Dictionary<string, string> userHash = hashType[KeySet(keys)];
|
||||||
if (userHash.ContainsKey(field))
|
if (userHash.ContainsKey(field))
|
||||||
|
|
@ -213,6 +211,8 @@ namespace Server.System
|
||||||
else
|
else
|
||||||
userHash[field] = value;
|
userHash[field] = value;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
hashType.Add(KeySet(keys), new Dictionary<string, string> { { field, value } });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -231,9 +231,21 @@ namespace Server.System
|
||||||
Dictionary<string, string> hash = new Dictionary<string, string>();
|
Dictionary<string, string> hash = new Dictionary<string, string>();
|
||||||
if (local)
|
if (local)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> hashs = new Dictionary<string, string>(hashType[KeySet(keys)]);
|
Dictionary<string, string> hashs;
|
||||||
foreach (var entry in hashs)
|
if (hashType.ContainsKey(KeySet(keys)))
|
||||||
hash.Add(entry.Key, entry.Value);
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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 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 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 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
|
#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 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 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");
|
public static readonly Redis redis = new Redis("192.168.1.2", 6379, 1, "xPEz3x08xQ8G1Fa");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue