🎈 perf(dispatch): 路由使用redis
This commit is contained in:
@@ -31,7 +31,7 @@ import { getBattleListOfMain, getMainChapter } from './normalBattleService';
|
||||
import { GuildModel, GuildType } from '../db/Guild';
|
||||
import UserGuild, { UserGuildType } from '../db/UserGuild';
|
||||
import { getAllGuildActivityStatus } from './guildActivity/guildActivityService';
|
||||
import { getAllOnlineRoles, getAllServers, incConnectorNum } from './redisService';
|
||||
import { getAllOnlineRoles, getAllServers, incConnectorNum, redisClient } from './redisService';
|
||||
import Item, { ItemModel } from '../db/Item';
|
||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
import { getDonation } from './donateService';
|
||||
@@ -47,7 +47,7 @@ import { getSurvey } from './gmService';
|
||||
import { ComBattleTeamModel } from '../db/ComBattleTeam';
|
||||
import { INFO_WINDOW } from '../pubUtils/dicParam';
|
||||
import { getLadderData } from './ladderService';
|
||||
import { dispatch } from '../util/dispatcher';
|
||||
import { dispatch } from '../pubUtils/dispatcher';
|
||||
import { PvpDataReturn } from '../domain/battleField/pvp';
|
||||
import { getHiddenData } from './dataService';
|
||||
import { ArtifactModel } from '../db/Artifact';
|
||||
@@ -349,12 +349,12 @@ export async function kickUser(app: Application, uid: string, message = STATUS.L
|
||||
|
||||
export async function assignServer(roleId: string, session: FrontendOrBackendSession) {
|
||||
try {
|
||||
let activity = _assignServer(roleId, 'activity');
|
||||
let battle = _assignServer(roleId, 'battle');
|
||||
let chat = _assignServer(roleId, 'chat');
|
||||
let guild = _assignServer(roleId, 'guild');
|
||||
let role = _assignServer(roleId, 'role');
|
||||
let order = _assignServer(roleId, 'order');
|
||||
let activity = await _assignServer(roleId, 'activity');
|
||||
let battle = await _assignServer(roleId, 'battle');
|
||||
let chat = await _assignServer(roleId, 'chat');
|
||||
let guild = await _assignServer(roleId, 'guild');
|
||||
let role = await _assignServer(roleId, 'role');
|
||||
let order = await _assignServer(roleId, 'order');
|
||||
if(activity) {
|
||||
session.set('activityServer', activity);
|
||||
session.push('activityServer', () => { });
|
||||
@@ -384,7 +384,7 @@ export async function assignServer(roleId: string, session: FrontendOrBackendSes
|
||||
}
|
||||
}
|
||||
|
||||
function _assignServer(roleId: string, serverType: string) {
|
||||
async function _assignServer(roleId: string, serverType: string) {
|
||||
let servers = pinus.app.getServersByType(serverType)||[];
|
||||
let sum = servers.reduce((pre, cur) => pre + (cur['num']||0), 0);
|
||||
let id = '';
|
||||
@@ -394,7 +394,7 @@ function _assignServer(roleId: string, serverType: string) {
|
||||
id = server?.id;
|
||||
}
|
||||
if(!id) {
|
||||
id = dispatch(roleId, servers, serverType)?.id;
|
||||
id = (await dispatch(redisClient(), roleId, servers, serverType))?.id;
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { GUILD_ACTIVITY_STATUS, GET_POINT_WAYS, GUILD_ACTIVITY_TYPE, REDIS_KEY,
|
||||
import { Record, UserGuildActivityRecModel } from "../../db/UserGuildActivityRec";
|
||||
import { GateMembersRec, CityParam, WoodenHorse, RaceActivityRankParam } from "../../domain/battleField/guildActivity";
|
||||
import { DicGuildActivity } from "../../pubUtils/dictionary/DicGuildActivity";
|
||||
import { getAllServers, getRoleOnlineInfo } from "../redisService";
|
||||
import { getAllServers, getRoleOnlineInfo, redisClient } from "../redisService";
|
||||
import { SimpleGuildRankParam, SimpleRoleRankParam, GuildRankInfo, RoleRankInfo } from "../../domain/rank";
|
||||
import { pinus } from "pinus";
|
||||
import { GuildActivityRecordModel } from "../../db/GuildActivityRec";
|
||||
@@ -32,7 +32,7 @@ import { getRandSingleEelm } from "../../pubUtils/util";
|
||||
import { CounterModel } from "../../db/Counter";
|
||||
import { setInterval } from "timers";
|
||||
import { DicRaceActivity } from "../../pubUtils/dictionary/DicRaceActivity";
|
||||
import { dispatch } from "../../util/dispatcher";
|
||||
import { dispatch } from "../../pubUtils/dispatcher";
|
||||
import { GuildModel } from "../../db/Guild";
|
||||
|
||||
let gateActivityObj: GateActivityObject;
|
||||
@@ -897,7 +897,7 @@ export async function resetJoinWoodenHorse() {
|
||||
let guild = pinus.app.getServersByType('guild');
|
||||
let recs = await GuildActivityRecordModel.findRecs(GUILD_ACTIVITY_TYPE.RACE_ACTIVITY, joinIndex);
|
||||
for(let { serverId, guildCode, joinMember } of recs) {
|
||||
let server = dispatch(`${serverId}`, guild);
|
||||
let server = await dispatch(redisClient(), `${serverId}`, guild, 'guild');
|
||||
if(server.id != pinus.app.getServerId()) continue;
|
||||
|
||||
for(let { roleId, roleName, job, code} of joinMember) {
|
||||
@@ -954,7 +954,7 @@ export async function leaveRaceActivity(serverId: number, guildCode: string, rol
|
||||
|
||||
export async function leaveRaceActivityToRemote(serverId: number, guildCode: string, roleId: string) {
|
||||
let guildServers = pinus.app.getServersByType('guild')||[];
|
||||
let server = dispatch(`${serverId}`, guildServers);
|
||||
let server = await dispatch(redisClient(), `${serverId}`, guildServers, 'guild');
|
||||
if(server) {
|
||||
await pinus.app.rpc.guild.guildActivityRemote.leaveRaceActivity.toServer(server.id, serverId, guildCode, roleId);
|
||||
}
|
||||
@@ -970,7 +970,7 @@ export async function leaveRaceWhenQuitGuild(serverId: number, guildCode: string
|
||||
|
||||
export async function leaveRaceWhenQuitGuildToRemote(serverId: number, guildCode: string, roleId: string) {
|
||||
let guildServers = pinus.app.getServersByType('guild')||[];
|
||||
let server = dispatch(`${serverId}`, guildServers);
|
||||
let server = await dispatch(redisClient(), `${serverId}`, guildServers, 'guild');
|
||||
if(server) {
|
||||
await pinus.app.rpc.guild.guildActivityRemote.leaveRaceWhenQuitGuild.toServer(server.id, serverId, guildCode, roleId);
|
||||
}
|
||||
@@ -986,7 +986,7 @@ export async function leaveRaceWhenDismiss(guildCode: string, serverId: number)
|
||||
|
||||
export async function leaveRaceWhenDismissToRemote(serverId: number, guildCode: string) {
|
||||
let guildServers = pinus.app.getServersByType('guild')||[];
|
||||
let server = dispatch(`${serverId}`, guildServers);
|
||||
let server = await dispatch(redisClient(), `${serverId}`, guildServers, 'guild');
|
||||
if(server) {
|
||||
await pinus.app.rpc.guild.guildActivityRemote.leaveRaceWhenDismiss.toServer(server.id, guildCode, serverId);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ import { pinus } from "pinus";
|
||||
import { GVG_CATAPULT, GVG_PERIOD } from "../../consts";
|
||||
import { GVGTeamModel, GVGTeamType } from "../../db/GVGTeam";
|
||||
import { GVGTeamMem } from "../../domain/battleField/gvgBattle";
|
||||
import { dispatch } from "../../util/dispatcher";
|
||||
import { dispatch } from "../../pubUtils/dispatcher";
|
||||
import { getGVGPeriodData } from "./gvgService";
|
||||
import { redisClient } from "../redisService";
|
||||
|
||||
// 积分点占领情况,groupId_serverType_cityId -> GVGBattleData
|
||||
const gvgBattleMap: Map<string, GVGBattleData> = new Map();
|
||||
@@ -244,7 +245,7 @@ export async function initTeamToMem() {
|
||||
let teams = await GVGTeamModel.findByConfigId(configId);
|
||||
for(let team of teams) {
|
||||
if(team.isBroken) continue;
|
||||
if(dispatch(team.cityId.toString(), servers)?.id == sid) {
|
||||
if((await dispatch(redisClient(), team.cityId.toString(), servers, 'guild'))?.id == sid) {
|
||||
let teamObj = getGVGBattleData(team.groupKey);
|
||||
teamObj.enterCity(team);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { GVGHeroInfo, PvpEnemies, PvpHeroInfo } from "../../domain/dbGeneral";
|
||||
import { getGroupKey, getGVGConfig, getGVGConfigFromRemote, getGVGPeriodData } from "./gvgService";
|
||||
import { GVGLeaguePrepareModel } from "../../db/GVGLeaguePrepare";
|
||||
import { pinus } from "pinus";
|
||||
import { dispatch } from "../../util/dispatcher";
|
||||
import { dispatch } from "../../pubUtils/dispatcher";
|
||||
import { Rank } from "../rankService";
|
||||
import { KeyNameParam, LeagueRankInfo, myIdInter, RoleRankInfo } from "../../domain/rank";
|
||||
import { findKeys, getAllServerName, redisClient } from "../redisService";
|
||||
@@ -358,7 +358,7 @@ export async function gvgBattleStart() {
|
||||
let { configId } = getGVGConfig();
|
||||
let guardCities = await GVGCityModel.findAllGuardCities(configId);
|
||||
for(let { cityId, groupKey, guardLeague, guardLeagueName } of guardCities) {
|
||||
let sid = dispatch(cityId.toString(), servers)?.id;
|
||||
let sid = (await dispatch(redisClient(), cityId.toString(), servers, 'guild'))?.id;
|
||||
await pinus.app.rpc.guild.guildRemote.initCatapult.toServer(sid, cityId, groupKey, guardLeague, guardLeagueName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ import { FrontendOrBackendSession, pinus } from "pinus";
|
||||
import { shouldRefresh, shouldRefreshWeek } from '../pubUtils/util';
|
||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
||||
import { refDailyTask, refDailyTaskBox } from './task/taskService'
|
||||
import { dispatch } from "../util/dispatcher";
|
||||
import { dispatch } from "../pubUtils/dispatcher";
|
||||
import { sendMessageToUserWithSuc } from "./pushService";
|
||||
import { PUSH_ROUTE } from "../consts";
|
||||
import { isDebugTime } from "../pubUtils/sdkUtil";
|
||||
import { redisClient } from "./redisService";
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
@@ -19,7 +20,7 @@ export async function refresh(session: FrontendOrBackendSession) {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PUSH_CURRENT_TIME, { time: Date.now() }, sid);
|
||||
} else {
|
||||
let guilds = pinus.app.getServersByType('guild');
|
||||
let guild = dispatch(roleId, guilds, 'guild');
|
||||
let guild = await dispatch(redisClient(), roleId, guilds, 'guild');
|
||||
let currentTime = await pinus.app.rpc.guild.guildActivityRemote.getCurrentTime.toServer(guild.id);
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PUSH_CURRENT_TIME, { time: currentTime }, sid);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PVPConfigModel, PVPConfigType } from '../db/PvpConfig';
|
||||
import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil';
|
||||
import { getTodayGuildActivity, gameData } from '../pubUtils/data';
|
||||
import { pvpSeasonEnd } from './pvpService';
|
||||
import { getAllOnlineRoles, getAllServers, delGuildActivityRank, getServerCreateTime } from './redisService';
|
||||
import { getAllOnlineRoles, getAllServers, delGuildActivityRank, getServerCreateTime, redisClient } from './redisService';
|
||||
import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_TIMER, ACTIVITY_TYPE, PUSH_ROUTE, STATUS, LADDER_STATUS, LADDER_SERVER_GAP_TIME, GVG_PERIOD, SDK_PUSH_MSG_TYPE, MAIL_TYPE } from '../consts';
|
||||
import { pinus } from 'pinus';
|
||||
import { settleGuildWeekly } from './guildService';
|
||||
@@ -12,7 +12,7 @@ import { sendMailByContent, SendMailFun, sendMailsByGmMail, } from './mailServic
|
||||
import { sendEndMsgToAllServer, sendGuildActivityStatus, setPreDayActiveData, incCurGuildActivityIndex } from './guildActivity/guildActivityService';
|
||||
import { sendUngotDividendJob, startGuildAuction, startWorldAuction, stopAuction } from './auctionService';
|
||||
import { DicGuildActivity } from '../pubUtils/dictionary/DicGuildActivity';
|
||||
import { dispatch } from '../util/dispatcher';
|
||||
import { dispatch } from '../pubUtils/dispatcher';
|
||||
import { initMarquee, setServerMainten } from './gmService';
|
||||
import moment = require('moment');
|
||||
import { reportOneOnline } from './authenticateService';
|
||||
@@ -323,7 +323,7 @@ export async function guildActivityStart(dicGuildActivity?: DicGuildActivity) {
|
||||
// 开始活动
|
||||
let guildServers = pinus.app.getServersByType('guild');
|
||||
for (let serverId of servers) {
|
||||
let sid = dispatch(serverId.toString(), guildServers, 'guild');
|
||||
let sid = await dispatch(redisClient(), serverId.toString(), guildServers, 'guild');
|
||||
await pinus.app.rpc.guild.guildActivityRemote.raceActivityStart.toServer(sid.id, serverId);
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ export async function raceActivitySeconds() {
|
||||
let servers = await getAllServers(); // 玩家serverId列表
|
||||
let guildServers = pinus.app.getServersByType('guild');
|
||||
for (let serverId of servers) {
|
||||
let sid = dispatch(serverId.toString(), guildServers, 'guild');
|
||||
let sid = await dispatch(redisClient(), serverId.toString(), guildServers, 'guild');
|
||||
await pinus.app.rpc.guild.guildActivityRemote.calWoodenHorseAndSend.toServer(sid.id, serverId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user