diff --git a/game-server/app/servers/connector/handler/entryHandler.ts b/game-server/app/servers/connector/handler/entryHandler.ts index ba6cfec7f..eb85a5640 100644 --- a/game-server/app/servers/connector/handler/entryHandler.ts +++ b/game-server/app/servers/connector/handler/entryHandler.ts @@ -6,7 +6,7 @@ import { Application, HandlerService, pinus, } from 'pinus'; import { FrontendSession } from 'pinus'; import { HeroModel } from './../../../db/Hero'; import { genCode, generateStr, resResult } from '../../../pubUtils/util'; -import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE, LOG_TYPE, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT } from '../../../consts'; +import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE, LOG_TYPE, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT, PUSH_ROUTE } from '../../../consts'; // import { loginRefresh } from '../../../services/playerEventService'; import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil'; import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin } from '../../../services/redisService'; @@ -25,6 +25,7 @@ import { ItemModel } from '../../../db/Item'; import { SkinModel } from '../../../db/Skin'; import { HeroParam } from '../../../domain/roleField/hero'; import { getAp } from '../../../services/actionPointService'; +import { sendMessageToAllWithSuc } from '../../../services/pushService'; export default function (app: Application) { new HandlerService(app, {}); @@ -346,14 +347,14 @@ export class EntryHandler { return resResult(STATUS.SUCCESS, { user: token }); } - async debugPushRefToOnlineUsers(msg: { magicWord: string }, session: FrontendSession) { - const { magicWord } = msg; + async debugPushRefToOnlineUsers(msg: { magicWord: string, todayZeroPoint: number }, session: FrontendSession) { + const { magicWord, todayZeroPoint } = msg; console.log('debugQueryTokenById msg:', msg); if (magicWord !== DEBUG_MAGIC_WORD) { return resResult(STATUS.TOKEN_ERR); } - await everydayRefresh(); + await sendMessageToAllWithSuc(PUSH_ROUTE.REFRESH_TIME, { todayZeroPoint }); return resResult(STATUS.SUCCESS); } } \ No newline at end of file diff --git a/game-server/app/services/pushService.ts b/game-server/app/services/pushService.ts index e76d8f0ae..a17e66e3d 100644 --- a/game-server/app/services/pushService.ts +++ b/game-server/app/services/pushService.ts @@ -18,7 +18,7 @@ export async function sendMessageToAll(route: string, data: any) { if (++i < n) { let users = allOnlineUsers.slice(i * PUSH_BATCH, (i + 1) * PUSH_BATCH - 1); let uids = users.map(cur => ({ uid: cur.roleId, sid: cur.sid })); - pinus.app.channelService.pushMessageByUids(route, data, uids); + pinus.app.get('channelService').pushMessageByUids(route, data, uids); } else { clearInterval(interval); } diff --git a/game-server/config/database.ts b/game-server/config/database.ts index d9ba02525..547e02f59 100644 --- a/game-server/config/database.ts +++ b/game-server/config/database.ts @@ -32,7 +32,7 @@ module.exports = { }, 'monitor': { 'mongo': 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', - 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', + 'gmmongo': 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzmon?replicaSet=mgset-505529944', 'redis': 'r-8vb130185rp2ir3lqn.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_monitor_2021' }, diff --git a/game-server/config/servers.ts b/game-server/config/servers.ts index a26cc06a7..952ac3db6 100644 --- a/game-server/config/servers.ts +++ b/game-server/config/servers.ts @@ -210,15 +210,15 @@ module.exports = { ], 'role': [ { 'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053 }, - { 'id': 'role-server-2', 'host': '127.0.0.1', 'port': 6061 }, - { 'id': 'role-server-3', 'host': '127.0.0.1', 'port': 6062 }, + // { 'id': 'role-server-2', 'host': '127.0.0.1', 'port': 6061 }, + // { 'id': 'role-server-3', 'host': '127.0.0.1', 'port': 6062 }, ], 'battle': [ { 'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054 } ], 'gate': [ { 'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3014, 'frontend': true }, - { 'id': 'gate-server-2', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3015, 'frontend': true } + // { 'id': 'gate-server-2', 'host': '127.0.0.1', 'clientHost': 'zyz_monitor.trgame.cn', 'clientPort': 3015, 'frontend': true } ], 'gm': [ { 'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055 } @@ -228,7 +228,7 @@ module.exports = { ], 'guild': [ { 'id': 'guild-server-1', 'host': '127.0.0.1', 'port': 6057, "args": " --inspect=9239" }, - { 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" } + // { 'id': 'guild-server-2', 'host': '127.0.0.1', 'port': 6058, "args": " --inspect=9240" } ], 'activity': [ { 'id': 'activity-server-1', 'host': '127.0.0.1', 'port': 6059, "args": " --inspect=9241" }, diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index 776b3491b..712382a34 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -25,37 +25,42 @@ export default class GameController extends Controller { } public async getServerList() { - const { ctx } = this; - let { uid, clientVersion } = ctx; - console.log('clientVersion', clientVersion); - let serverList = new Array(); - let loginServerList = new Array(); + try { + const { ctx } = this; + let { uid, clientVersion } = ctx; + console.log('clientVersion', clientVersion); + let serverList = new Array(); + let loginServerList = new Array(); - let allServers = await ServerlistModel.findByEnv(ctx.app.config.realEnv); - let roles = await RoleModel.findAllByUid(uid, true, true); - for (let server of allServers) { - let curGroup = serverList.find(cur => cur.groupId == server.groupId); - if (!curGroup) { - curGroup = new GroupParam(server); - serverList.push(curGroup); + let allServers = await ServerlistModel.findByEnv(ctx.app.config.realEnv); + let roles = await RoleModel.findAllByUid(uid, true, true); + for (let server of allServers) { + let curGroup = serverList.find(cur => cur.groupId == server.groupId); + if (!curGroup) { + curGroup = new GroupParam(server); + serverList.push(curGroup); + } + curGroup.pushServer(server); + + let role = roles.find(role => role.serverId == server.id); + if (!!role) { + let curLoginInfo = new ServerParamWithRole(role, server); + loginServerList.push(curLoginInfo); + } } - curGroup.pushServer(server); - let role = roles.find(role => role.serverId == server.id); - if (!!role) { - let curLoginInfo = new ServerParamWithRole(role, server); - loginServerList.push(curLoginInfo); + loginServerList.sort((a, b) => { return b.updatedAt.getTime() - a.updatedAt.getTime() }); + + if (serverList) { + ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { serverList, loginServerList }); + } else { + ctx.body = ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND); } - } + return - loginServerList.sort((a, b) => { return b.updatedAt.getTime() - a.updatedAt.getTime() }); - - if (serverList) { - ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { serverList, loginServerList }); - } else { - ctx.body = ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND); + }catch(e) { + console.error(e); } - return } public async newServer() { diff --git a/web-server/config/config.monitor.ts b/web-server/config/config.monitor.ts index 8b228325f..695058858 100644 --- a/web-server/config/config.monitor.ts +++ b/web-server/config/config.monitor.ts @@ -8,6 +8,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.gmmongoose = { + url: 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzmon?replicaSet=mgset-505529944', // 内网 + options: { useNewUrlParser: true, useUnifiedTopology: true }, + }; config.redis = { url: 'r-8vb130185rp2ir3lqn.redis.zhangbei.rds.aliyuncs.com', // 内网 pw: 'zyz_monitor_2021'