Example #1
0
        internal void DelUsers(params ulong[] users)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;

            foreach (ulong user in users)
            {
                foreach (WeakReference info in m_Users.Values)
                {
                    UserInfo userInfo = info.Target as UserInfo;
                    if (userInfo != null)
                    {
                        JsonMessageSyncQuitRoom syncQuitRoomMsg = new JsonMessageSyncQuitRoom();
                        syncQuitRoomMsg.m_Guid     = userInfo.Guid;
                        syncQuitRoomMsg.m_QuitGuid = user;
                        JsonMessageDispatcher.SendDcoreMessage(userInfo.NodeName, syncQuitRoomMsg);
                        LogSys.Log(LOG_TYPE.DEBUG, "SyncQuitRoom,receiver:{0},guid:{1}", userInfo.Guid, user);
                    }
                }
            }
            foreach (ulong user in users)
            {
                UserInfo info = dataProcess.GetUserInfo(user);
                if (null != info)
                {
                    info.Room       = null;
                    info.IsPrepared = false;
                    LogSys.Log(LOG_TYPE.DEBUG, "LeaveRoom:{0}", user);
                }
                m_Users.Remove(user);
            }
            UpdateUserCount();
        }
Example #2
0
 internal void HandleQueryArenaMatchGroup(ulong guid)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "---got query match group msg! id=" + guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         return;
     }
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaMatchGroupResult);
     resultMsg.m_Guid = guid;
     int cur_user_rank = ArenaSystem.UNKNOWN_RANK;
     ArenaInfo arena_info = m_ArenaSystem.GetArenaInfoById(guid);
     if (arena_info != null)
     {
         cur_user_rank = arena_info.GetRank();
     };
     List<MatchGroup> match_groups = m_ArenaSystem.QueryMatchArena(cur_user_rank, 3);
     ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult();
     foreach (MatchGroup group in match_groups)
     {
         ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData group_msg = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData();
         group_msg.One = ArenaUtil.CreateArenaInfoMsg(group.One);
         group_msg.Two = ArenaUtil.CreateArenaInfoMsg(group.Two);
         group_msg.Three = ArenaUtil.CreateArenaInfoMsg(group.Three);
         if (group_msg.One == null || group_msg.Two == null || group_msg.Three == null)
         {
             continue;
         }
         protoData.m_MatchGroups.Add(group_msg);
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "---send match group msg! id=" + guid);
 }
Example #3
0
        internal void StartBattleRoom()
        {
            this.CurrentState = RoomState.Game;  //房间进入游戏状态
            RoomServerInfo svrInfo;

            if (m_LobbyInfo.RoomServerInfos.TryGetValue(m_RoomServerName, out svrInfo))
            {
                foreach (WeakReference userRef in m_Users.Values)
                {
                    UserInfo info = userRef.Target as UserInfo;
                    if (info != null)
                    {
                        JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                        startGameResultMsg.m_Guid = info.Guid;
                        ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                        protoData.server_ip   = svrInfo.ServerIp;
                        protoData.server_port = svrInfo.ServerPort;
                        protoData.key         = info.Key;
                        protoData.hero_id     = info.HeroId;
                        protoData.camp_id     = info.CampId;
                        protoData.scene_type  = SceneType;
                        protoData.result      = (int)GeneralOperationResult.LC_Succeed;

                        startGameResultMsg.m_ProtoData = protoData;

                        JsonMessageDispatcher.SendDcoreMessage(info.NodeName, startGameResultMsg);
                        LogSys.Log(LOG_TYPE.DEBUG, "StartGameResult, guid:{0},key:{1},ip:{2},port:{3},hero:{4},camp:{5},scene:{6}", info.Guid, info.Key, svrInfo.ServerIp, svrInfo.ServerPort, info.HeroId, protoData.camp_id, SceneType);
                    }
                }
            }
        }
Example #4
0
 internal void HandleRequestExpeditionInfo(ulong guid, int hp, int mp, int rage, int request_num, bool is_reset, bool allow_cost_gold, long timestamp)
 {
     long c_DeltaTime = 60 * 10;
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user != null && null != user.Expedition)
     {
         GeneralOperationResult result = GeneralOperationResult.LC_Failure_Unknown;
         long dif_time = Convert.ToInt64(TimeUtility.CurTimestamp) - timestamp;
         bool is_valid_timestamp = Math.Abs(dif_time) <= c_DeltaTime ? true : false;
         if (is_reset && !is_valid_timestamp)
         {
             result = GeneralOperationResult.LC_Failure_Time;
         }
         else
         {
             result = user.Expedition.RequestExpeditionInfo(guid, request_num, is_reset, m_UsableImages);
         }
         if (GeneralOperationResult.LC_Succeed == result)
         {
             user.Expedition.SyncExpeditionInfo(guid, hp, mp, rage, request_num, result);
         }
         else
         {
             JsonMessageWithGuid resetMsg = new JsonMessageWithGuid(JsonMessageID.ExpeditionResetResult);
             resetMsg.m_Guid = guid;
             ArkCrossEngineMessage.Msg_LC_ExpeditionResetResult protoData = new ArkCrossEngineMessage.Msg_LC_ExpeditionResetResult();
             protoData.m_Result = (int)result;
             resetMsg.m_ProtoData = protoData;
             JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resetMsg);
         }
     }
 }
Example #5
0
 internal void HandleQueryArenaInfo(ulong guid)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "---got query arena info msg! id=" + guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     if (user == null)
     {
         return;
     }
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaInfoResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaInfoResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaInfoResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     if (own_arena == null)
     {
         own_arena = m_ArenaSystem.CreateArenaInfo(user);
     }
     else if (own_arena.IsNeedUpdate(user))
     {
         own_arena.UpdateArenaInfo(user);
     }
     m_ArenaSystem.ResetArenaFightCount(own_arena);
     protoData.m_ArenaInfo = ArenaUtil.CreateArenaInfoMsg(own_arena, false);
     protoData.m_LeftBattleCount = own_arena.LeftFightCount;
     protoData.m_CurFightCountByTime = own_arena.FightCountBuyTime;
     long passed_time = (long)(DateTime.Now - own_arena.LastBattleTime).TotalMilliseconds;
     protoData.m_BattleLeftCDTime = m_ArenaSystem.BaseConfig.BattleCd - passed_time;
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "---send query arena info msg! id=" + guid);
 }
Example #6
0
        internal bool LeaveGroup(GroupInfo group, GroupMemberInfo member)
        {
            if (null == group || null == member)
            {
                return(false);
            }
            if (member.Guid == group.CreatorGuid && group.Members.Count > 1)
            {
                m_Groups.Remove(group.CreatorGuid);
                group.CreatorGuid = group.Members[1].Guid;
                if (!m_Groups.ContainsKey(group.CreatorGuid))
                {
                    m_Groups.Add(group.CreatorGuid, group);
                }
                ///
                UserInfo leader = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(group.CreatorGuid);
                if (null != leader)
                {
                    JsonMessageWithGuid slgMsg = new JsonMessageWithGuid(JsonMessageID.ChangeCaptain);
                    slgMsg.m_Guid = group.CreatorGuid;
                    ArkCrossEngineMessage.Msg_LC_ChangeCaptain protoData = new ArkCrossEngineMessage.Msg_LC_ChangeCaptain();
                    protoData.m_CreatorGuid = group.CreatorGuid;
                    slgMsg.m_ProtoData      = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(leader.NodeName, slgMsg);
                }
            }
            bool result = group.Members.Remove(member);

            if (group.Members.Count == 0)
            {
                recycles.Enqueue(group);
            }
            return(result);
        }
Example #7
0
        internal void SyncMissionList(UserInfo user)
        {
            JsonMessageResetDailyMissions gm_msg = new JsonMessageResetDailyMissions();

            gm_msg.m_Missions = new MissionInfoForSync[user.Mission.CompletedMissions.Count + user.Mission.UnCompletedMissions.Count];
            int count = 0;

            foreach (MissionInfo mi in user.Mission.MissionList.Values)
            {
                MissionInfoForSync mis = new MissionInfoForSync();
                if (MissionStateType.COMPLETED == mi.State)
                {
                    mis.m_IsCompleted = true;
                }
                else if (MissionStateType.UNCOMPLETED == mi.State)
                {
                    mis.m_IsCompleted = false;
                }
                else
                {
                    continue;
                }
                mis.m_MissionId          = mi.MissionId;
                mis.m_Progress           = MissionSystem.Instance.GetMissionProgress(user, mi, mis.m_IsCompleted);
                gm_msg.m_Missions[count] = mis;
                count++;
            }
            gm_msg.m_Guid = user.Guid;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, gm_msg);
        }
Example #8
0
        internal void DismissGroup(GroupInfo group)
        {
            if (null == group)
            {
                return;
            }
            UserInfo          leader = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(group.CreatorGuid);
            TeamOperateResult result = TeamOperateResult.OR_Dismiss;

            foreach (GroupMemberInfo m in group.Members)
            {
                UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(m.Guid);
                if (null != user)
                {
                    JsonMessageWithGuid msg = new JsonMessageWithGuid(JsonMessageID.SyncLeaveGroup);
                    msg.m_Guid = m.Guid;
                    ArkCrossEngineMessage.Msg_LC_SyncLeaveGroup protoData = new ArkCrossEngineMessage.Msg_LC_SyncLeaveGroup();
                    if (null != leader)
                    {
                        protoData.m_GroupNick = leader.Nickname;
                    }
                    protoData.m_Result = (int)result;
                    msg.m_ProtoData    = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(leader.NodeName, msg);
                    user.Group = null;
                }
            }
            m_Groups.Remove(group.CreatorGuid);
            if (null != group.Members)
            {
                group.Members.Clear();
            }
            recycles.Enqueue(group);
        }
Example #9
0
        internal void AllocLobbyRoom(ulong[] users, int type)
        {
            int  roomId = m_LobbyInfo.CreateAutoRoom(users, type);
            long time   = TimeUtility.GetServerMilliseconds();

            DataProcessScheduler dataProcess    = LobbyServer.Instance.DataProcessScheduler;
            JsonMessageWithGuid  matchResultMsg = new JsonMessageWithGuid(JsonMessageID.MatchResult);

            foreach (ulong user in users)
            {
                UserInfo info = dataProcess.GetUserInfo(user);
                if (info != null)
                {
                    info.LastNotifyMatchTime = time;
                    matchResultMsg.m_Guid    = user;
                    ArkCrossEngineMessage.Msg_LC_MatchResult protoData = new ArkCrossEngineMessage.Msg_LC_MatchResult();
                    protoData.m_Result         = (int)TeamOperateResult.OR_Succeed;
                    matchResultMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(info.NodeName, matchResultMsg);
                    ///
                    dataProcess.RecordCampaignAction(user, type);
                }
            }

            LogSys.Log(LOG_TYPE.DEBUG, "Alloc lobby room for {0} users, roomid {1} scene {2}", users.Length, roomId, type);
        }
Example #10
0
        internal void NotifyRequestDare(ulong userGuid, string targetNickname)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);

            if (null == user)
            {
                return;
            }
            ulong    targetGuid = LobbyServer.Instance.DataProcessScheduler.GetGuidByNickname(targetNickname);
            UserInfo target     = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(targetGuid);

            if (null == target)
            {
                return;
            }
            long cur_time = TimeUtility.GetServerMilliseconds();

            if (cur_time - user.LastRequestDareTime > CHALLENGE_CD_MS)
            {
                user.LastRequestDareTime = TimeUtility.GetServerMilliseconds();
                JsonMessageWithGuid rdMsg = new JsonMessageWithGuid(JsonMessageID.RequestDare);
                rdMsg.m_Guid = targetGuid;
                ArkCrossEngineMessage.Msg_LC_RequestDare protoData = new ArkCrossEngineMessage.Msg_LC_RequestDare();
                protoData.m_ChallengerNickname = user.Nickname;
                rdMsg.m_ProtoData = protoData;
                JsonMessageDispatcher.SendDcoreMessage(target.NodeName, rdMsg);
            }
            else
            {
                NotifyRequestDareResult(userGuid, user.Nickname, GeneralOperationResult.LC_Failure_InCd);
            }
        }
Example #11
0
 internal void HandleArenaBuyFightCount(ulong guid, int handle)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "--handle arena buy fight count!");
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaBuyFightCountResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaBuyFightCountResult();
     ArenaInfo own_arena = m_ArenaSystem.GetArenaInfoById(guid);
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
     protoData.CurBuyTime = 0;
     protoData.CurFightCount = 0;
     protoData.Result = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
     if (own_arena != null && user != null && scheduler != null)
     {
         ArenaBuyFightCountConfig buy_config = ArenaConfigProvider.Instance.BuyFightCountConfig.GetDataById(own_arena.FightCountBuyTime + 1);
         if (user.Vip >= buy_config.RequireVipLevel && user.Gold >= buy_config.Cost)
         {
             if (own_arena.LeftFightCount < own_arena.MaxFightCount)
             {
                 own_arena.FightCountBuyTime += 1;
                 own_arena.LeftFightCount = own_arena.MaxFightCount;
                 protoData.Result = (int)GeneralOperationResult.LC_Succeed;
             }
             else
             {
                 protoData.Result = (int)GeneralOperationResult.LC_Failure_Full;
             }
             protoData.CurBuyTime = own_arena.FightCountBuyTime;
             protoData.CurFightCount = own_arena.LeftFightCount;
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "--send arena buy fight count result!");
 }
Example #12
0
        internal void HandleBuyLife(ulong guid)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;

            if (null == scheduler)
            {
                return;
            }
            // 响应玩家要求复活
            UserInfo user   = scheduler.GetUserInfo(guid);
            bool     result = false;

            if (null != user)
            {
                int reliveStoneId = ItemConfigProvider.Instance.GetReliveStoneId();
                if (user.ItemBag.GetItemCount(reliveStoneId, 0) >= 1)
                {
                    scheduler.ConsumeItem(guid, user.ItemBag.GetItemData(reliveStoneId, 0), 1, GainItemType.Props, ConsumeItemWay.BuyLife, false, "BuyLife");
                    result = true;
                }
                else if (user.Gold >= 50)
                {
                    int consume = 50;
                    scheduler.ConsumeAsset(guid, consume, ConsumeAssetType.BuyLife, AssetType.Glod, "BuyLife");
                    result = true;
                }
                if (result)
                {
                    user.CurrentBattleInfo.DeadCount += 1;
                    if (null != user.Room)
                    {
                        Msg_LR_UserReLive.Builder resultBuilder = Msg_LR_UserReLive.CreateBuilder();
                        RoomInfo room = m_LobbyInfo.GetRoomByID(user.CurrentRoomID);
                        resultBuilder.SetUserGuid(guid);
                        resultBuilder.SetRoomID(user.CurrentRoomID);
                        LobbyServer.Instance.RoomSvrChannel.Send(room.RoomServerName, resultBuilder.Build());
                    }
                    JsonMessageWithGuid blrMsg = new JsonMessageWithGuid(JsonMessageID.BuyLifeResult);
                    blrMsg.m_Guid = guid;
                    ArkCrossEngineMessage.Msg_LC_BuyLifeResult protoData = new ArkCrossEngineMessage.Msg_LC_BuyLifeResult();
                    protoData.m_Succeed    = result;
                    protoData.m_CurDiamond = (int)user.Gold;
                    blrMsg.m_ProtoData     = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, blrMsg);
                }
                else
                {
                    JsonMessageWithGuid blrMsg = new JsonMessageWithGuid(JsonMessageID.BuyLifeResult);
                    blrMsg.m_Guid = guid;
                    ArkCrossEngineMessage.Msg_LC_BuyLifeResult protoData = new ArkCrossEngineMessage.Msg_LC_BuyLifeResult();
                    protoData.m_Succeed    = result;
                    protoData.m_CurDiamond = (int)user.Gold;
                    blrMsg.m_ProtoData     = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, blrMsg);
                }
            }
            //JsonMessageDispatcher.SendDcoreMessage(user.NodeName, );
        }
Example #13
0
 private void OnMessage(uint seq, int source_handle, int dest_handle,
                        IntPtr data, int len)
 {
     try
     {
         if (IsUnknownServer(source_handle))
         {
             StringBuilder sb = new StringBuilder(256);
             if (CenterClientApi.TargetName(source_handle, sb, 256))
             {
                 string name = sb.ToString();
                 if (name.StartsWith("NodeJs"))
                 {
                     m_NodeHandles.Add(source_handle);
                 }
                 else if (name.StartsWith("RoomSvr"))
                 {
                     m_RoomSvrHandles.Add(source_handle);
                 }
             }
         }
         byte[] bytes = new byte[len];
         Marshal.Copy(data, bytes, 0, len);
         if (IsNode(source_handle))
         {
             if (!GlobalVariables.Instance.IsWaitQuit)
             {
                 JsonMessageDispatcher.HandleDcoreMessage(seq, source_handle, dest_handle, bytes);
             }
         }
         else if (IsRoomServer(source_handle))
         {
             m_RoomSvrChannel.Dispatch(source_handle, seq, bytes);
         }
         else if (IsBridge(source_handle))
         {
             m_BridgeChannel.Dispatch(source_handle, seq, bytes);
         }
         else if (IsStore(source_handle))
         {
             m_StoreChannel.Dispatch(source_handle, seq, bytes);
         }
         else if (IsGmServer(source_handle))
         {
             m_GmSvrChannel.Dispatch(source_handle, seq, bytes);
         }
     }
     catch (Exception ex)
     {
         LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
     }
 }
Example #14
0
        private void SendResultMsg(ChallengeInfo info, UserInfo user)
        {
            if (user == null)
            {
                return;
            }
            JsonMessageWithGuid retMsg = new JsonMessageWithGuid(ArkCrossEngine.JsonMessageID.ArenaChallengeResult);

            retMsg.m_Guid = user.Guid;
            ArkCrossEngineMessage.Msg_LC_ArenaChallengeResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaChallengeResult();
            protoData.m_ChallengeInfo = ArenaUtil.CreateChallengeInfoData(info);
            retMsg.m_ProtoData        = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, retMsg);
        }
Example #15
0
        internal void GetStarList(ulong guid, int start, int count)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user      = scheduler.GetUserInfo(guid);

            if (null != user)
            {
                if (start < 0)
                {
                    start = 0;
                }
                int ct  = m_GowStars.Count;
                int end = start + count;
                if (end > ct)
                {
                    end = ct;
                }
                JsonMessageWithGuid aaMsg = new JsonMessageWithGuid(JsonMessageID.SyncGowStarList);
                aaMsg.m_Guid = guid;
                ArkCrossEngineMessage.Msg_LC_SyncGowStarList protoData = new ArkCrossEngineMessage.Msg_LC_SyncGowStarList();
                for (int i = start; i < end; ++i)
                {
                    UserInfo member = scheduler.GetUserInfo(m_GowStars[i].m_Guid);
                    if (null != member)
                    {
                        m_GowStars[i].m_Level         = member.Level;
                        m_GowStars[i].m_FightingScore = member.FightingScore;
                    }
                    ArkCrossEngineMessage.Msg_LC_SyncGowStarList.GowStarInfoForMessage info = new ArkCrossEngineMessage.Msg_LC_SyncGowStarList.GowStarInfoForMessage();
                    info.m_Guid                     = m_GowStars[i].m_Guid;
                    info.m_GowElo                   = m_GowStars[i].m_GowElo;
                    info.m_Nick                     = m_GowStars[i].m_Nick;
                    info.m_HeroId                   = m_GowStars[i].m_HeroId;
                    info.m_Level                    = m_GowStars[i].m_Level;
                    info.m_FightingScore            = m_GowStars[i].m_FightingScore;
                    info.m_RankId                   = m_GowStars[i].m_RankId;
                    info.m_Point                    = m_GowStars[i].m_Point;
                    info.m_CriticalTotalMatches     = m_GowStars[i].m_CriticalTotalMatches;
                    info.m_CriticalAmassWinMatches  = m_GowStars[i].m_CriticalAmassWinMatches;
                    info.m_CriticalAmassLossMatches = m_GowStars[i].m_CriticalAmassLossMatches;
                    protoData.m_Stars.Add(info);
                }
                if (protoData.m_Stars.Count > 0)
                {
                    aaMsg.m_ProtoData = protoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, aaMsg);
                }
            }
        }
        internal void AccountLogin(string accountKey, int opcode, int channelId, string data, int login_server_id, string client_game_version, string client_login_ip, string unique_identifier, string system, string game_channel_id, string nodeName)
        {
            ServerBridgeThread bridgeThread = LobbyServer.Instance.ServerBridgeThread;

            if (bridgeThread.CurActionNum < 30000)
            {
                LogSys.Log(LOG_TYPE.INFO, "Account connected: {0}, Login type: AccountLogin", accountKey);
            }
            /// Normlog
            LogSys.NormLog("serverevent", LobbyConfig.AppKeyStr, LobbyConfig.LogNormVersionStr, system, game_channel_id,
                           unique_identifier, "null", (int)ServerEventCode.VerifyToken, client_game_version);
            //账号登录模式下,首先向Billing服务器验证账号,获取accountId
            //注意这里的回调执行线程是在ServerBridgeThread线程。
            VerifyAccount(accountKey, opcode, channelId, data, (BillingClient.VerifyAccountCB)((a, ret, accountId) =>
            {
                if (ret == true)
                {
                    if (m_KickedUsers.ContainsKey(accountId))
                    {
                        LogSys.Log(LOG_TYPE.WARN, ConsoleColor.Green, "Account verify success but user is a kicked user. account:{0}, id:{1}", accountKey, accountId);

                        JsonMessageAccountLoginResult replyMsg = new JsonMessageAccountLoginResult();
                        replyMsg.m_Account   = accountKey;
                        replyMsg.m_AccountId = "";
                        replyMsg.m_Result    = (int)AccountLoginResult.Error;
                        JsonMessageDispatcher.SendDcoreMessage(nodeName, replyMsg);
                    }
                    else
                    {
                        LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "Account verify success. account:{0}, id:{1}", accountKey, accountId);

                        DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                        dataProcess.DispatchAction(dataProcess.DoAccountLogin, accountKey, accountId, login_server_id, client_game_version, client_login_ip, unique_identifier, system, game_channel_id, nodeName);
                    }
                }
                else
                {
                    LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "Account verify failed. account:{0}", accountKey);
                    JsonMessageAccountLoginResult replyMsg = new JsonMessageAccountLoginResult();
                    replyMsg.m_Account   = accountKey;
                    replyMsg.m_AccountId = "";
                    replyMsg.m_Result    = (int)AccountLoginResult.Error;
                    JsonMessageDispatcher.SendDcoreMessage(nodeName, replyMsg);
                }
                /// norm log
                LogSys.NormLog("serverevent", LobbyConfig.AppKeyStr, LobbyConfig.LogNormVersionStr, system, game_channel_id,
                               unique_identifier, accountId, (int)ServerEventCode.VerifyResult, client_game_version);
            }));
        }
Example #17
0
        internal void SendModuleMail(ModuleMailInfo moduleMail, int validityPeriod)
        {
            moduleMail.m_MailGuid   = GenMailGuid();
            moduleMail.m_SendTime   = DateTime.Now;
            moduleMail.m_ExpiryDate = moduleMail.m_SendTime.AddDays(validityPeriod);
            m_ModuleMails.Add(moduleMail);
            JsonMessageNotifyNewMail newMailMsg  = new JsonMessageNotifyNewMail();
            DataProcessScheduler     dataProcess = LobbyServer.Instance.DataProcessScheduler;

            dataProcess.VisitUsers((UserInfo userInfo) =>
            {
                newMailMsg.m_Guid = userInfo.Guid;
                JsonMessageDispatcher.SendDcoreMessage(userInfo.NodeName, newMailMsg);
            });
        }
Example #18
0
        //响应RoomServer玩家重新连接进入房间的反馈消息
        internal void OnReplyReconnectUser(ulong userGuid, int roomID, bool isSuccess)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);

            if (user == null)
            {
                return;
            }
            if (isSuccess)
            {
                user.CurrentState = UserState.Room;
                RoomInfo room = m_LobbyInfo.GetRoomByID(roomID);
                if (null != room)
                {
                    RoomServerInfo svrInfo;
                    if (m_LobbyInfo.RoomServerInfos.TryGetValue(room.RoomServerName, out svrInfo))
                    {
                        if (null != svrInfo)
                        {
                            JsonMessageWithGuid startGameResultMsg = new JsonMessageWithGuid(JsonMessageID.StartGameResult);
                            startGameResultMsg.m_Guid = user.Guid;
                            ArkCrossEngineMessage.Msg_LC_StartGameResult protoData = new ArkCrossEngineMessage.Msg_LC_StartGameResult();
                            protoData.server_ip   = svrInfo.ServerIp;
                            protoData.server_port = svrInfo.ServerPort;
                            protoData.key         = user.Key;
                            protoData.hero_id     = user.HeroId;
                            protoData.camp_id     = user.CampId;
                            protoData.scene_type  = room.SceneType;
                            protoData.match_key   = user.CurrentBattleInfo.MatchKey;
                            protoData.result      = (int)GeneralOperationResult.LC_Succeed;

                            startGameResultMsg.m_ProtoData = protoData;
                            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, startGameResultMsg);
                            //重新进入房间成功
                            LogSys.Log(LOG_TYPE.INFO, "User Reconnected RoomServer Success ! , guid:{0}", userGuid);
                        }
                    }
                }
            }
            else
            {
                user.CurrentState = UserState.Online;

                LogSys.Log(LOG_TYPE.INFO, "User Reconnected RoomServer Failed ! , guid:{0}", userGuid);
            }
        }
Example #19
0
 internal void HandleExchangeGift(ulong userGuid, string giftcode)
 {
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(userGuid);
     if (user == null)
     {
         return;
     }
     int giftId = 0;
     GeneralOperationResult ret = m_GiftCodeSystem.ExchangeGift(userGuid, giftcode, out giftId);
     JsonMessageWithGuid jsonMsg = new JsonMessageWithGuid(JsonMessageID.ExchangeGiftResult);
     jsonMsg.m_Guid = userGuid;
     ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult protoData = new ArkCrossEngineMessage.Msg_LC_ExchangeGiftResult();
     protoData.m_GiftId = giftId;
     protoData.m_Result = (int)ret;
     jsonMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(user.NodeName, jsonMsg);
 }
Example #20
0
        internal void HandleArenaStartChallenge(ulong guid, ulong target_guid)
        {
            LogSys.Log(LOG_TYPE.DEBUG, "---got start challenge result msg! id=" + guid);
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
            if (user == null)
            {
                return;
            }
            ArenaInfo target_arena_info = m_ArenaSystem.GetArenaInfoById(target_guid);

            JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaStartChallengeResult);
            resultMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_ArenaStartCallengeResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaStartCallengeResult();
            protoData.m_TargetGuid = target_guid;
            protoData.m_Sign = new Random().Next();
            if (target_arena_info != null && target_arena_info.IsNeedUpdate(user))
            {
                target_arena_info.UpdateArenaInfo(user);
            }
            bool start_ret = m_ArenaSystem.StartChallenge(guid, target_guid, protoData.m_Sign);
            if (target_arena_info == null)
            {
                protoData.m_ResultCode = (int)GeneralOperationResult.LC_Failure_Arena_NotFindTarget;
            }
            else if (!start_ret)
            {
                protoData.m_ResultCode = (int)m_ArenaSystem.ErrorCode;
            }
            else
            {
                user.UpdateGuideFlag((int)MatchSceneEnum.Arena);
                user.CurrentState = UserState.Pve;
                protoData.m_ResultCode = (int)GeneralOperationResult.LC_Succeed;
                ChallengeInfo challenge = m_ArenaSystem.GetDoingChallengeInfo(guid);
                if (challenge != null && challenge.Target != null)
                {
                    float coefficent = ChallengeChecker.CalcPvpCoefficient(user.Level, target_arena_info.Level);
                    int total_hp = ChallengeChecker.CalcPlayerHp(target_arena_info, coefficent);
                    challenge.Target.TotalHp = total_hp;
                    //LogSys.Log(LOG_TYPE.DEBUG, "challenge target totalhp={0}", total_hp);
                }
            }
            resultMsg.m_ProtoData = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg);
            LogSys.Log(LOG_TYPE.DEBUG, "---send start challenge result msg! id=" + guid);
        }
Example #21
0
        internal void NotifyRequestDareResult(ulong guid, string nickname, GeneralOperationResult result)
        {
            UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);

            if (null == user)
            {
                return;
            }
            JsonMessageWithGuid rdMsg = new JsonMessageWithGuid(JsonMessageID.RequestDareResult);

            rdMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_RequestDareResult protoData = new ArkCrossEngineMessage.Msg_LC_RequestDareResult();
            protoData.m_Nickname = nickname;
            protoData.m_Result   = (int)result;
            rdMsg.m_ProtoData    = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, rdMsg);
        }
Example #22
0
        private void ProvideGowPrize(ulong guid, GowPrizeConfig cfg)
        {
            DataProcessScheduler scheduler = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user      = scheduler.GetUserInfo(guid);

            if (null == user)
            {
                return;
            }
            JsonMessageWithGuid pgpMsg = new JsonMessageWithGuid(JsonMessageID.RequestGowPrize);

            pgpMsg.m_Guid = guid;
            ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult protoData = new ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult();
            if (user.GowInfo.IsAcquirePrize)
            {
                protoData.m_Result = (int)GeneralOperationResult.LC_Failure_Unknown;
            }
            else
            {
                int money_incr = cfg.Money;
                int gold_incr  = cfg.Gold;
                protoData.m_Money = money_incr;
                protoData.m_Gold  = gold_incr;
                scheduler.DispatchAction(scheduler.DoAddAssets, guid, money_incr, gold_incr, 0, 0, GainConsumePos.Gow.ToString());
                if (null != cfg.Items && cfg.Items.Count > 0)
                {
                    for (int i = 0; i < cfg.Items.Count; ++i)
                    {
                        GowPrizeItem item = cfg.Items[i];
                        if (null != item)
                        {
                            scheduler.DispatchAction(scheduler.DoAddItem, guid, item.ItemId, item.ItemNum, GainConsumePos.Gow.ToString());
                            ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult.AwardItemInfo itemDataMsg =
                                new ArkCrossEngineMessage.Msg_LC_RequestGowPrizeResult.AwardItemInfo();
                            itemDataMsg.m_Id  = item.ItemId;
                            itemDataMsg.m_Num = item.ItemNum;
                            protoData.m_Items.Add(itemDataMsg);
                        }
                    }
                }
                protoData.m_Result          = (int)GeneralOperationResult.LC_Succeed;
                user.GowInfo.IsAcquirePrize = true;
            }
            pgpMsg.m_ProtoData = protoData;
            JsonMessageDispatcher.SendDcoreMessage(user.NodeName, pgpMsg);
        }
Example #23
0
 internal void HandleArenaQueryRank(ulong guid, int handle)
 {
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaQueryRankResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult();
     ArenaInfo cur_info = m_ArenaSystem.GetArenaInfoById(guid);
     if (cur_info != null)
     {
         List<ArenaInfo> result = m_ArenaSystem.QueryRankList(cur_info.GetRank());
         for (int i = 0; i < result.Count; i++)
         {
             protoData.RankMsg.Add(ArenaUtil.CreateArenaInfoMsg(result[i]));
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "send query rank list!");
 }
Example #24
0
        internal void RegisterNodeJs(NodeInfo info)
        {
            NodeInfo info_;

            if (!m_LobbyInfo.NodeInfos.TryGetValue(info.NodeName, out info_))
            {
                m_LobbyInfo.NodeInfos.Add(info.NodeName, info);
            }
            else
            {
                info_.NodeName = info.NodeName;
            }
            JsonMessageNodeJsRegisterResult resultMsg = new JsonMessageNodeJsRegisterResult();

            resultMsg.m_IsOk = true;
            JsonMessageDispatcher.SendDcoreMessage(info.NodeName, resultMsg);

            LogSys.Log(LOG_TYPE.DEBUG, "RegisterNodeJs,name:{0}", info.NodeName);
        }
Example #25
0
        internal void CheckAndSyncMissions(UserInfo user, StageClearInfo info = null)
        {
            List <int> completedMissions = new List <int>();

            OnStageClear(user, info, ref completedMissions);
            foreach (int missionId in completedMissions)
            {
                JsonMessageWithGuid missionCompletedMsg = new JsonMessageWithGuid(JsonMessageID.MissionCompleted);
                missionCompletedMsg.m_Guid = user.Guid;
                ArkCrossEngineMessage.Msg_LC_MissionCompleted missionProtoData = new ArkCrossEngineMessage.Msg_LC_MissionCompleted();
                if (null != missionProtoData)
                {
                    missionProtoData.m_MissionId    = missionId;
                    missionProtoData.m_Progress     = MissionSystem.Instance.GetMissionProgress(user, missionId, true);
                    missionCompletedMsg.m_ProtoData = missionProtoData;
                    JsonMessageDispatcher.SendDcoreMessage(user.NodeName, missionCompletedMsg);
                }
            }
        }
Example #26
0
 internal void RequestStartGame(UserInfo userInfo)
 {
     if (null != userInfo)
     {
         userInfo.IsPrepared = true;
         foreach (WeakReference info in m_Users.Values)
         {
             UserInfo user = info.Target as UserInfo;
             if (user != null)
             {
                 JsonMessageSyncPrepared syncPreparedMsg = new JsonMessageSyncPrepared();
                 syncPreparedMsg.m_Guid         = user.Guid;
                 syncPreparedMsg.m_PreparedGuid = userInfo.Guid;
                 JsonMessageDispatcher.SendDcoreMessage(user.NodeName, syncPreparedMsg);
             }
         }
         LogSys.Log(LOG_TYPE.DEBUG, "RequestStartGame,guid:{0}", userInfo.Guid);
     }
 }
Example #27
0
 internal void HandleArenaQueryHistory(ulong guid, int handle)
 {
     LogSys.Log(LOG_TYPE.DEBUG, "--handle arena query history!");
     JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaQueryHistoryResult);
     resultMsg.m_Guid = guid;
     ArkCrossEngineMessage.Msg_LC_ArenaQueryHistoryResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaQueryHistoryResult();
     UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid);
     List<ChallengeInfo> history = m_ArenaSystem.QueryHistory(guid);
     if (history != null)
     {
         foreach (ChallengeInfo info in history)
         {
             ArkCrossEngineMessage.ChallengeInfoData info_data = ArenaUtil.CreateChallengeInfoData(info);
             protoData.ChallengeHistory.Add(info_data);
         }
     }
     resultMsg.m_ProtoData = protoData;
     JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
     LogSys.Log(LOG_TYPE.DEBUG, "--send arena query history result!");
 }
Example #28
0
 ///=====================================================================================================
 /// 这里定义供其它线程通过QueueAction调用的函数,实际执行线程是GmServerThread。
 ///=====================================================================================================
 internal void GMPQueryUser(ulong userGuid, ulong targetGuid, int handle)
 {
     if (true == m_GmSeverAvailable)
     {
         GMPQueryUser(targetGuid, (GMPLoadUserCB)((ret, data) =>
         {
             JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.GmQueryInfoByGuidOrNickname);
             resultMsg.m_Guid = userGuid;
             ArkCrossEngineMessage.Msg_LC_GmQueryInfoByGuidOrNickname protoData = new ArkCrossEngineMessage.Msg_LC_GmQueryInfoByGuidOrNickname();
             protoData.m_Result = 1;
             if (ret == DSLoadResult.Success)
             {
                 DS_UserInfo dataUser = data.UserBasic;
                 protoData.m_Info = UserInfoBuilder(dataUser);
                 protoData.m_Result = (int)ret;
                 resultMsg.m_ProtoData = protoData;
             }
             JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg);
         }));
     }
 }
        internal void DirectLogin(string accountKey, int loginServerId, string nodeName)
        {
            LogSys.Log(LOG_TYPE.INFO, "Account connected: {0}, Login type: DirectLogin", accountKey);
            //直接登录模式下默认accountId与设备标识accountKey相同
            //TO DO:不同设备的设备标识会不会有重复?会不会与Billing返回的accountId重复?
            string accountId = accountKey;

            if (m_KickedUsers.ContainsKey(accountId))
            {
                JsonMessageAccountLoginResult replyMsg = new JsonMessageAccountLoginResult();
                replyMsg.m_Account   = accountKey;
                replyMsg.m_AccountId = "";
                replyMsg.m_Result    = (int)AccountLoginResult.Error;
                JsonMessageDispatcher.SendDcoreMessage(nodeName, replyMsg);
            }
            else
            {
                DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                dataProcess.DispatchAction(dataProcess.DoAccountLogin, accountKey, accountId, loginServerId, "", "", "", "", "", nodeName);
            }
        }
Example #30
0
        internal void SendUserMail(MailInfo userMail, int validityPeriod)
        {
            userMail.m_MailGuid   = GenMailGuid();
            userMail.m_SendTime   = DateTime.Now;
            userMail.m_ExpiryDate = userMail.m_SendTime.AddDays(validityPeriod);
            List <MailInfo> mails = null;

            if (!m_UserMails.TryGetValue(userMail.m_Receiver, out mails))
            {
                mails = new List <MailInfo>();
                m_UserMails.Add(userMail.m_Receiver, mails);
            }
            mails.Add(userMail);
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userMail.m_Receiver);

            if (null != user && user.CurrentState != UserState.DropOrOffline)
            {
                JsonMessageNotifyNewMail newMailMsg = new JsonMessageNotifyNewMail();
                newMailMsg.m_Guid = userMail.m_Receiver;
                JsonMessageDispatcher.SendDcoreMessage(user.NodeName, newMailMsg);
            }
        }