public bool TryAdd(fmLord lord) { bool b = m_lords.TryAdd(lord.AccId, lord); Print(); return(b); }
public void Logout(fmLord lord) { if (null == lord) { Logger.Debug("LordManager Logout: lord == null"); return; } fmLord outLord = null; if (true == m_lords.TryRemove(lord.AccId, out outLord)) { Print(); //if (outLord.State == eLordState.Maze) //{ // outLord.Logout(); //} //else { using (outLord) { outLord.Logout(); } } //Logger.Debug("LordManager TryRemove"); } //Logger.Debug("LordManager Logout"); lord = null; }
// 1. 매칭을 어떻게 해야 할까? private bool MatchingUser(fmLord lord, out fmLord target) { target = null; int gapLv = 5; int minLv = lord.GetLv() <= gapLv ? 1 : lord.GetLv() - gapLv; int maxLv = lord.GetLv() + gapLv; maxLv = 70 <= maxLv ? 70 : maxLv; DateTime limitTime = fmServerTime.Now.AddMinutes(-20); List <fmLord> rndlist = new List <fmLord>(); int cnt = m_lords.Count; for (int i = cnt - 1; 0 <= i; --i) { fmLord node = m_lords.ElementAt(i).Value; if (lord == node) { continue; } if (node.GetLv() < minLv) { continue; } if (maxLv < node.GetLv()) { continue; } if (node.State == eLordState.Logout) { continue; } if (node.ActTime < limitTime) { continue; } rndlist.Add(node); if (30 < rndlist.Count) { break; } } if (rndlist.Count <= 0) { return(false); } target = rndlist[m_random.Next(0, rndlist.Count)]; rndlist.Clear(); rndlist = null; return(true); }
public override void Process() { // 기본 영주 정보 얻어오기 fmLord lord = null; m_session.TryGetLord(out lord); // 프로토콜 RQ using (var recvfmProtocol = new PT_CG_Item_Equip_RQ()) { // 프로토콜 Read recvfmProtocol.Deserialize(m_recvPacket); // 프로토콜 RS using (var sendfmProtocol = new PT_CG_Item_Equip_RS()) { // check if (null == lord) { sendfmProtocol.m_eErrorCode = eErrorCode.Auth_PleaseLogin; m_session.SendPacket(sendfmProtocol); return; } // check state if (lord.State != eLordState.Normal) { sendfmProtocol.m_eErrorCode = eErrorCode.Auth_PleaseLogin; m_session.SendPacket(sendfmProtocol); return; } // 아이템 장착 lord.TryEquip(recvfmProtocol, sendfmProtocol); // 프로토콜 send m_session.SendPacket(sendfmProtocol); if (sendfmProtocol.m_eErrorCode == eErrorCode.Success) { // 로그 남기기 ArchiveExecuter.Instance.Push(new Msg_Log_Act(m_server.dbLog(), new fmLogAct { Time = fmServerTime.Now, PType = sendfmProtocol.GeteProtocolType(), AccId = lord.AccId, Lv = lord.GetLv(), Gold = lord.GetGold(), C1 = lord.GetRuby(), C2 = lord.GetStone(), } )); } } } }
public void SetLord(fmLord lord, appServer server) { m_server = server as GameServer; m_lord = lord; if (null != m_lord) { m_lord.State = eLordState.Normal; m_lord.SessionId = GetNumber(); } }
public override eErrorCode Execute() { var db = GetDatabase(); if (false == db.IsExistsLord(i_biAccID)) { return(eErrorCode.Lord_NoneExist); } o_lord = new fmLord(); o_lord.ActTime = fmServerTime.Now; o_lord.State = eLordState.Login; try { o_lord.AccId = i_biAccID; fmLordBase lordInfo = null; rdStat lordStat = null; List <rdItem> items = null; List <rdMission> missions = null; List <rdMap> maps = null; fmMissionBase missionBase = null; List <rdInDun> inDuns = null; db.GetLordBase(i_biAccID, out lordInfo); db.GetLordStat(i_biAccID, out lordStat); db.GetLordItems(i_biAccID, out items); db.GetMissions(i_biAccID, out missions); db.GetMaps(i_biAccID, out maps); db.GetMissionBase(i_biAccID, out missionBase); db.GetLordInDuns(i_biAccID, out inDuns); o_lord.InitLordBase(lordInfo); o_lord.InitStat(lordStat); o_lord.InitItems(items); } catch (Exception ex) { Logger.Error("accid:{0}, ex:{1}", i_biAccID, ex.ToString()); return(eErrorCode.Query_Fail); } if (true == o_lord.Block) { return(eErrorCode.Server_Block); } return(eErrorCode.Success); }
public bool TryGetLord(out fmLord lord) { if (null != m_lord) { m_lord.ActTime = fmServerTime.Now; } lord = m_lord; if (null == lord) { return(false); } else { return(true); } }
public override void Process() { // 기본 영주 정보 얻어오기 fmLord lord = null; m_session.TryGetLord(out lord); // 프로토콜 RQ using (var recvfmProtocol = new PT_CG_Lord_GetLord_RQ()) { // 프로토콜 Read recvfmProtocol.Deserialize(m_recvPacket); // 프로토콜 RS using (var sendfmProtocol = new PT_CG_Lord_GetLord_RS()) { if (null == lord) { sendfmProtocol.m_eErrorCode = eErrorCode.Auth_PleaseLogin; m_session.SendPacket(sendfmProtocol); return; } using (var query = new urq_GetOtherLord(eRedis.Game)) { query.i_strName = recvfmProtocol.Name; sendfmProtocol.m_eErrorCode = query.Execute(); if (sendfmProtocol.m_eErrorCode == eErrorCode.Success) { sendfmProtocol.Lv = query.o_lordBase.Lv; sendfmProtocol.Items = query.o_items.Where(x => x.Equip == true).ToList(); } } m_session.SendPacket(sendfmProtocol); } } }
public override void Process() { // 기본 영주 정보 얻어오기 fmLord lord = null; m_session.TryGetLord(out lord); // 프로토콜 RQ using (var recvfmProtocol = new PT_CG_Rank_GetList_RQ()) { recvfmProtocol.Deserialize(m_recvPacket); using (var sendfmProtocol = new PT_CG_Rank_GetList_RS()) { if (null == lord) { sendfmProtocol.m_eErrorCode = eErrorCode.Auth_PleaseLogin; m_session.SendPacket(sendfmProtocol); return; } using (var db = new urq_GetRank(eRedis.Game)) { db.i_rankerKey = new fmRankerKey { AccId = lord.AccId, Name = lord.GetName() }; sendfmProtocol.m_eErrorCode = db.Execute(); sendfmProtocol.m_list = db.o_rankers; sendfmProtocol.m_nMyRank = db.o_myRank; m_session.SendPacket(sendfmProtocol); } } } }
public override void Process() { // 기본 영주 정보 얻어오기 fmLord lord = null; m_session.TryGetLord(out lord); // 프로토콜 RQ using (var recvfmProtocol = new PT_CG_Item_GetList_RQ()) { // 프로토콜 Read recvfmProtocol.Deserialize(m_recvPacket); // 프로토콜 RS using (var sendfmProtocol = new LZ4_PT_CG_Item_GetList_RS()) { // check if (null == lord) { sendfmProtocol.m_eErrorCode = eErrorCode.Auth_PleaseLogin; m_session.SendPacket(sendfmProtocol); return; } // check state if (lord.State != eLordState.Normal) { sendfmProtocol.m_eErrorCode = eErrorCode.Auth_PleaseLogin; m_session.SendPacket(sendfmProtocol); return; } // 아이템 정보 얻기 lord.TryGetItems(sendfmProtocol); // 프로토콜 전송 m_session.SendPacket(sendfmProtocol); } } }
public override void Process() { fmLord lord = null; //Logger.Debug("Msg_Session_Remove start"); if (true == m_session.TryGetLord(out lord)) { //Logger.Debug("TryGetLord lord"); //if (lord.State == eLordState.Maze) //{ // //BattleExecuter.Instance.Push(new Msg_Maze_Delegate_Leave(lord)); //} //else { LordManager.Instance.Logout(lord); } } //Logger.Debug("Msg_Session_Remove end"); ClientSessionManager.Instance.Remove(m_session); }
public bool TryFind(long accid, out fmLord lord) { return(m_lords.TryGetValue(accid, out lord)); }
public bool CheckLogin(long accid, out fmLord lord) { return(m_lords.TryGetValue(accid, out lord)); }
public override void Process() { // 프로토콜 RQ using (var recvfmProtocol = new PT_CG_Lord_EnterWorld_RQ()) { // 프로토콜 Read recvfmProtocol.Deserialize(m_recvPacket); // 프로토콜 RS using (var sendfmProtocol = new PT_CG_Lord_EnterWorld_RS()) { eErrorCode err = eErrorCode.Success; long accid = 0; // db get token using (var db = new urq_GetToken(eRedis.Token)) { db.i_strToken = recvfmProtocol.m_strToken; err = db.Execute(); accid = db.o_biAccID; if (eErrorCode.Success != err) { sendfmProtocol.m_eErrorCode = err; m_session.SendPacket(sendfmProtocol); return; } } // 중복 처리 fmLord lord = null; if (true == LordManager.Instance.CheckLogin(accid, out lord)) { //if (lord.State == eLordState.Maze) //{ // // 유저의 응답 속도는 느려지겠지만 서버의 안정성을 보장 하진 못하나? // // 쓰레드 분리 // //BattleExecuter.Instance.Push(new Msg_Maze_Delegate_Leave_RQ(m_server, lord)); // return; //} long oldSessionId = lord.SessionId; //Logger.Debug("oldSessionId: {0}", oldSessionId); LordManager.Instance.Logout(lord); if (m_session.GetNumber() != oldSessionId) { ClientSessionManager.Instance.OutBeforeSession(oldSessionId); } } // db 영주 정보 using (var db = new urq_GetLord(eRedis.Game)) { db.i_biAccID = accid; err = db.Execute(); lord = db.o_lord; if (eErrorCode.Success == err) { if (true == LordManager.Instance.TryAdd(lord)) { m_session.SetLord(lord, m_server); lord.GetInformation(sendfmProtocol); } } sendfmProtocol.m_eErrorCode = err; m_session.SendPacket(sendfmProtocol); // 이렇게 한 이유는 패킷을 보내고 방송을 받기 위해서. if (eErrorCode.Success == err) { db.o_lord.State = eLordState.Normal; } } } } }
public Msg_Delegate_CreateLord_RQ(appServer server, ClientSession session, fmLord lord) { m_server = server; m_session = session; m_lord = lord; }
public override void Release() { i_biAccID = 0; o_lord = null; }