Exemplo n.º 1
0
        /// <summary>
        /// 匹配报名
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleId"></param>
        /// <param name="zoneId"></param>
        /// <param name="gameType"></param>
        /// <param name="groupIndex"></param>
        /// <returns></returns>
        public int TianTiSignUp(string userId, int roleId, int zoneId, int gameType, int groupIndex, int zhanDouLi)
        {
            int result;

            if (string.IsNullOrEmpty(userId) || roleId <= 0)
            {
                return(StdErrorCode.Error_Not_Exist);
            }

            userId = userId.ToUpper();
            int count = Interlocked.Increment(ref CurrentRequestCount);

            try
            {
                if (count < MaxRequestCount)
                {
                    lock (Mutex)
                    {
                        KuaFuRoleData kuaFuRoleData;
                        if (RoleId2RoleDataDict.TryGetValue(roleId, out kuaFuRoleData))
                        {
                            //如果服务器ID不同,表明是跨服登录角色,不应该在此报名
                            if (kuaFuRoleData.ServerId != ClientInfo.ServerId)
                            {
                                return(StdErrorCode.Error_Operation_Faild);
                            }
                        }
                    }

                    ITianTiService kuaFuService = GetKuaFuService();
                    if (null != kuaFuService)
                    {
                        try
                        {
                            TianTiGameData TianTiGameData = new TianTiGameData()
                            {
                                ZhanDouLi = zhanDouLi
                            };
                            result = kuaFuService.RoleSignUp(ClientInfo.ServerId, userId, zoneId, roleId, gameType, groupIndex, TianTiGameData);
                        }
                        catch (System.Exception ex)
                        {
                            ResetKuaFuService();
                        }
                    }
                    else
                    {
                        return(StdErrorCode.Error_Server_Not_Registed);
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
            finally
            {
                Interlocked.Decrement(ref CurrentRequestCount);
            }

            return(StdErrorCode.Error_Success);
        }