Exemple #1
0
        private void ExtractMailAttachment(MailInfo info, ulong userGuid)
        {
            DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;

            dataProcess.DispatchAction(dataProcess.DoAddAssets, userGuid, info.m_Money, info.m_Gold, 0, info.m_Stamina, GainConsumePos.Mail.ToString());

            int itemCt = info.m_Items.Count;

            for (int itemIx = 0; itemIx < itemCt; ++itemIx)
            {
                MailItem item = info.m_Items[itemIx];
                dataProcess.DispatchAction(dataProcess.DoAddItem, userGuid, item.m_ItemId, item.m_ItemNum, GainConsumePos.Mail.ToString());
            }
        }
Exemple #2
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);
        }
        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);
            }));
        }
        protected override void OnTick()
        {
            long curTime = TimeUtility.GetServerMilliseconds();

            if (m_LastLogTime + 60000 < curTime)
            {
                m_LastLogTime = curTime;
                DebugPoolCount((string msg) =>
                {
                    LogSys.Log(LOG_TYPE.INFO, "GmServerThread.ActionQueue {0}", msg);
                });
            }

            const int c_MaxIterationPerTick = 100;

            if (IsLobbyFull() || GetTotalQueueingCount() <= 0)
            {
                //大厅已经满或者没有排队的玩家,多休息1秒
                System.Threading.Thread.Sleep(1000);
            }
            else
            {
                DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                for (int i = 0; i < c_MaxIterationPerTick; ++i)
                {
                    foreach (KeyValuePair <int, Queue <string> > pair in m_QueueingAccounts)
                    {
                        int            serverId = pair.Key;
                        Queue <string> queue    = pair.Value;
                        if (queue.Count > 0 && CanEnter(serverId))
                        {
                            string accountKey = queue.Dequeue();
                            IncEnterCount(serverId);
                            LoginInfo info;
                            if (m_QueueingInfos.TryRemove(accountKey, out info) && info.LoginServerId == serverId)
                            {
                                dataProcess.DispatchAction(dataProcess.DoAccountLoginWithoutQueueing, accountKey, info.AccountId, info.LoginServerId, info.ClientGameVersion, info.ClientLoginIp, info.UniqueIdentifier, info.System, info.ChannelId, info.NodeName);
                                ++i;
                            }
                        }
                    }
                }
            }
        }
        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);
            }
        }
Exemple #6
0
 internal void CloseRoom()
 {
     //清空房间内玩家数据
     foreach (WeakReference info in m_Users.Values)
     {
         UserInfo user = info.Target as UserInfo;
         if (user != null)
         {
             if (user.CurrentState == UserState.Room)
             {
                 user.CurrentState = UserState.Online;
             }
             user.ResetRoomInfo();
             if (user.IsDisconnected)
             {
                 DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler;
                 dataProcess.DispatchAction(dataProcess.DoUserLogoff, user.Guid);
             }
         }
     }
     m_Users.Clear();
     this.CurrentState = RoomState.Close;  //房间进入关闭状态
     LogSys.Log(LOG_TYPE.INFO, "Lobby Room Close, roomID:{0}", RoomId);
 }
Exemple #7
0
        //领取礼品
        internal GeneralOperationResult ExchangeGift(ulong userGuid, string giftcode, out int giftId)
        {
            giftId = 0;
            GeneralOperationResult ret       = GeneralOperationResult.LC_Failure_Unknown;
            DataProcessScheduler   scheduler = LobbyServer.Instance.DataProcessScheduler;
            UserInfo user = scheduler.GetUserInfo(userGuid);

            if (null != user)
            {
                GiftCodeInfo giftcodeInfo = null;
                m_GiftCodes.TryGetValue(giftcode, out giftcodeInfo);
                if (giftcodeInfo != null)
                {
                    giftId = giftcodeInfo.GiftId;
                    Dictionary <int, int> giftCountDict = null;
                    if (m_UserGiftCountDict.TryGetValue(user.Guid, out giftCountDict))
                    {
                        int count = 0;
                        if (giftCountDict.TryGetValue(giftId, out count))
                        {
                            if (count >= s_UserMaxGiftCount)
                            {
                                //该种礼包的领取次数超过限制
                                ret = GeneralOperationResult.LC_Failure_Overflow;
                                return(ret);
                            }
                        }
                    }
                    if (giftcodeInfo.IsUsed == false)
                    {
                        //礼品码可用
                        GiftConfig giftConfig = GiftConfigProvider.Instance.GetDataById(giftcodeInfo.GiftId);
                        if (null != giftConfig)
                        {
                            //扣
                            giftcodeInfo.IsUsed   = true;
                            giftcodeInfo.UserGuid = userGuid;
                            if (giftCountDict != null)
                            {
                                int count = 0;
                                if (giftCountDict.TryGetValue(giftId, out count))
                                {
                                    giftCountDict[giftId]++;
                                }
                                else
                                {
                                    giftCountDict.Add(giftId, 1);
                                }
                            }
                            else
                            {
                                giftCountDict = new Dictionary <int, int>();
                                giftCountDict.Add(giftId, 1);
                                m_UserGiftCountDict.Add(userGuid, giftCountDict);
                            }
                            var ds_thread = LobbyServer.Instance.DataStoreThread;
                            if (ds_thread.DataStoreAvailable)
                            {
                                ds_thread.DSSaveGiftCode(giftcodeInfo, true);
                            }
                            //给
                            for (int i = 0; i < giftConfig.ItemIdList.Count; ++i)
                            {
                                if (giftConfig.ItemIdList[i] > 0)
                                {
                                    scheduler.DispatchAction(scheduler.DoAddItem, userGuid, giftConfig.ItemIdList[i], giftConfig.ItemNumList[i], GainConsumePos.Gift.ToString());
                                }
                            }
                            ret = GeneralOperationResult.LC_Succeed;
                        }
                    }
                    else
                    {
                        //礼品码已经使用
                        ret = GeneralOperationResult.LC_Failure_Code_Used;
                    }
                }
                else
                {
                    //礼品码错误
                    ret = GeneralOperationResult.LC_Failure_Code_Error;
                }
            }
            return(ret);
        }