rpc优化:所有remote加上try catch
This commit is contained in:
@@ -6,6 +6,7 @@ import { _getActivitiesByType, _getActivityById, _getActivities } from '../../..
|
|||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
import { taflush } from '../../../services/sdkService';
|
import { taflush } from '../../../services/sdkService';
|
||||||
import { ActivityInRemote } from '../../../domain/activityField/activityField';
|
import { ActivityInRemote } from '../../../domain/activityField/activityField';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -29,33 +30,41 @@ export class ActivityRemote {
|
|||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loadActivities() {
|
public async loadActivities() {
|
||||||
let servers = await ServerlistModel.findByEnv(this.app.get('env'));
|
try {
|
||||||
for(let { id: serverId, activityGroupId } of servers) {
|
let servers = await ServerlistModel.findByEnv(this.app.get('env'));
|
||||||
for(let groupId of activityGroupId) {
|
for(let { id: serverId, activityGroupId } of servers) {
|
||||||
if(!this.groupToServer.has(groupId)) {
|
for(let groupId of activityGroupId) {
|
||||||
this.groupToServer.set(groupId, []);
|
if(!this.groupToServer.has(groupId)) {
|
||||||
|
this.groupToServer.set(groupId, []);
|
||||||
|
}
|
||||||
|
this.groupToServer.get(groupId).push(serverId);
|
||||||
}
|
}
|
||||||
this.groupToServer.get(groupId).push(serverId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let activities = await ActivityModel.findOpenAndComingActivityes();
|
||||||
|
let activityIds: number[] = [];
|
||||||
|
for(let activity of activities) {
|
||||||
|
this.activities.set(activity.activityId, new ActivityInRemote(activity));
|
||||||
|
activityIds.push(activity.activityId);
|
||||||
|
}
|
||||||
|
this.setActivityTypeAndServer();
|
||||||
|
|
||||||
|
this.app.set('activityByServer', this.activityByServer);
|
||||||
|
this.app.set('activityByType', this.activityByType);
|
||||||
|
this.app.set('activities', this.activities);
|
||||||
|
this.app.set('groupToServer', this.groupToServer);
|
||||||
|
// console.log('****** loadActivities')
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let activities = await ActivityModel.findOpenAndComingActivityes();
|
|
||||||
let activityIds: number[] = [];
|
|
||||||
for(let activity of activities) {
|
|
||||||
this.activities.set(activity.activityId, new ActivityInRemote(activity));
|
|
||||||
activityIds.push(activity.activityId);
|
|
||||||
}
|
|
||||||
this.setActivityTypeAndServer();
|
|
||||||
|
|
||||||
this.app.set('activityByServer', this.activityByServer);
|
|
||||||
this.app.set('activityByType', this.activityByType);
|
|
||||||
this.app.set('activities', this.activities);
|
|
||||||
this.app.set('groupToServer', this.groupToServer);
|
|
||||||
// console.log('****** loadActivities')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private setActivityTypeAndServer() {
|
private setActivityTypeAndServer() {
|
||||||
@@ -87,76 +96,120 @@ export class ActivityRemote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async updateActivities(activities: ActivityInRemote[]) {
|
public async updateActivities(activities: ActivityInRemote[]) {
|
||||||
// console.log('******* activities', activities)
|
try {
|
||||||
let activityIds: number[] = [];
|
// console.log('******* activities', activities)
|
||||||
for(let activity of activities) {
|
let activityIds: number[] = [];
|
||||||
this.activities.set(activity.activityId, activity);
|
for(let activity of activities) {
|
||||||
activityIds.push(activity.activityId);
|
this.activities.set(activity.activityId, activity);
|
||||||
|
activityIds.push(activity.activityId);
|
||||||
|
}
|
||||||
|
this.setActivityTypeAndServer();
|
||||||
|
|
||||||
|
this.app.set('activityByServer', this.activityByServer);
|
||||||
|
this.app.set('activityByType', this.activityByType);
|
||||||
|
this.app.set('activities', this.activities);
|
||||||
|
this.app.set('groupToServer', this.groupToServer);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
this.setActivityTypeAndServer();
|
|
||||||
|
|
||||||
this.app.set('activityByServer', this.activityByServer);
|
|
||||||
this.app.set('activityByType', this.activityByType);
|
|
||||||
this.app.set('activities', this.activities);
|
|
||||||
this.app.set('groupToServer', this.groupToServer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteActivities(activityIds: number[]) {
|
public async deleteActivities(activityIds: number[]) {
|
||||||
for(let activityId of activityIds) {
|
try {
|
||||||
this.activities.delete(activityId);
|
for(let activityId of activityIds) {
|
||||||
|
this.activities.delete(activityId);
|
||||||
|
}
|
||||||
|
this.setActivityTypeAndServer();
|
||||||
|
|
||||||
|
this.app.set('activityByServer', this.activityByServer);
|
||||||
|
this.app.set('activityByType', this.activityByType);
|
||||||
|
this.app.set('activities', this.activities);
|
||||||
|
this.app.set('groupToServer', this.groupToServer);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
this.setActivityTypeAndServer();
|
|
||||||
|
|
||||||
this.app.set('activityByServer', this.activityByServer);
|
|
||||||
this.app.set('activityByType', this.activityByType);
|
|
||||||
this.app.set('activities', this.activities);
|
|
||||||
this.app.set('groupToServer', this.groupToServer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async saveGroupToServer(groupId: number, serverIds: number[]) {
|
public async saveGroupToServer(groupId: number, serverIds: number[]) {
|
||||||
this.groupToServer.set(groupId, serverIds);
|
try {
|
||||||
this.setActivityTypeAndServer();
|
this.groupToServer.set(groupId, serverIds);
|
||||||
|
this.setActivityTypeAndServer();
|
||||||
this.app.set('activityByServer', this.activityByServer);
|
|
||||||
this.app.set('activityByType', this.activityByType);
|
this.app.set('activityByServer', this.activityByServer);
|
||||||
this.app.set('activities', this.activities);
|
this.app.set('activityByType', this.activityByType);
|
||||||
this.app.set('groupToServer', this.groupToServer);
|
this.app.set('activities', this.activities);
|
||||||
|
this.app.set('groupToServer', this.groupToServer);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async saveActivitiesToGroup(groupId: number, activities: number[]) {
|
public async saveActivitiesToGroup(groupId: number, activities: number[]) {
|
||||||
for(let activityId of activities) {
|
try {
|
||||||
if(this.activities.get(activityId)) {
|
for(let activityId of activities) {
|
||||||
this.activities.get(activityId).groupId = groupId;
|
if(this.activities.get(activityId)) {
|
||||||
|
this.activities.get(activityId).groupId = groupId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.setActivityTypeAndServer();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
this.setActivityTypeAndServer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getActivityById(activityId: number) {
|
public getActivityById(activityId: number) {
|
||||||
return _getActivityById(activityId);
|
try {
|
||||||
|
return _getActivityById(activityId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getActivitiesByType(serverId: number, type: number) {
|
public getActivitiesByType(serverId: number, type: number) {
|
||||||
return _getActivitiesByType(serverId, type);
|
try {
|
||||||
|
return _getActivitiesByType(serverId, type);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getActivities() {
|
public getActivities() {
|
||||||
return _getActivities();
|
try {
|
||||||
|
return _getActivities();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
|||||||
import { reloadResources } from '../../../pubUtils/data';
|
import { reloadResources } from '../../../pubUtils/data';
|
||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
import { taflush } from '../../../services/sdkService';
|
import { taflush } from '../../../services/sdkService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -80,35 +81,63 @@ export class BattleRemote {
|
|||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public setPvpSeasonNum(pvpConfig: PVPConfigType) {
|
public setPvpSeasonNum(pvpConfig: PVPConfigType) {
|
||||||
if(pvpConfig) {
|
try {
|
||||||
this.app.set('pvpSeasonNum', pvpConfig.seasonNum);
|
if(pvpConfig) {
|
||||||
this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
|
this.app.set('pvpSeasonNum', pvpConfig.seasonNum);
|
||||||
|
this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initPvpSeasonNum() {
|
public async initPvpSeasonNum() {
|
||||||
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
|
try {
|
||||||
this.setPvpSeasonNum(pvpConfig);
|
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
|
||||||
|
this.setPvpSeasonNum(pvpConfig);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import { resResult } from '../../../pubUtils/util';
|
|||||||
import { STATUS } from '../../../consts';
|
import { STATUS } from '../../../consts';
|
||||||
import { handleComBtlProgress } from '../../../services/comBattleService';
|
import { handleComBtlProgress } from '../../../services/comBattleService';
|
||||||
import { MemComBtlTeam } from '../../../domain/battleField/ComBattleTeamField';
|
import { MemComBtlTeam } from '../../../domain/battleField/ComBattleTeamField';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -117,32 +118,40 @@ export class ComBattleRemote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async hurt(uid: string, sid: string, name: string, bossHurt: number, actorHurt: [{ actorId: number, actorHurt: number }]) {
|
public async hurt(uid: string, sid: string, name: string, bossHurt: number, actorHurt: [{ actorId: number, actorHurt: number }]) {
|
||||||
console.log('hurt channel name: ', name);
|
try {
|
||||||
let channelService = this.app.get('channelService');
|
console.log('hurt channel name: ', name);
|
||||||
this.bossHp -= bossHurt;
|
let channelService = this.app.get('channelService');
|
||||||
let channel = channelService.getChannel(name, false);
|
this.bossHp -= bossHurt;
|
||||||
if (!!channel) {
|
let channel = channelService.getChannel(name, false);
|
||||||
if (this.bossHp < 0) {
|
if (!!channel) {
|
||||||
this.bossHp = 0;
|
if (this.bossHp < 0) {
|
||||||
|
this.bossHp = 0;
|
||||||
|
}
|
||||||
|
channel.pushMessage('bossHp', resResult(STATUS.SUCCESS, { bossHp: this.bossHp }));
|
||||||
}
|
}
|
||||||
channel.pushMessage('bossHp', resResult(STATUS.SUCCESS, { bossHp: this.bossHp }));
|
return this.bossHp;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
return this.bossHp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async leaveFromBattle(roleId: string, teamCode: string ) {
|
public async leaveFromBattle(roleId: string, teamCode: string ) {
|
||||||
let teamMap: Map<string, MemComBtlTeam> = this.app.get('teamMap');
|
try {
|
||||||
if(teamMap && teamMap.has(teamCode)) {
|
let teamMap: Map<string, MemComBtlTeam> = this.app.get('teamMap');
|
||||||
let myTeam = teamMap.get(teamCode);
|
if(teamMap && teamMap.has(teamCode)) {
|
||||||
for(let roleStatus of myTeam.roleStatus) {
|
let myTeam = teamMap.get(teamCode);
|
||||||
if(roleStatus.roleId == roleId) {
|
for(let roleStatus of myTeam.roleStatus) {
|
||||||
roleStatus.battleStatus = 2; // 自己失败了
|
if(roleStatus.roleId == roleId) {
|
||||||
|
roleStatus.battleStatus = 2; // 自己失败了
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
let channelService = this.app.get('channelService');
|
||||||
|
let channel = channelService.getChannel(teamCode, false);
|
||||||
|
|
||||||
|
await handleComBtlProgress(myTeam, this.app.get('robotHurtTimer'), teamMap, channel); // 结算
|
||||||
}
|
}
|
||||||
let channelService = this.app.get('channelService');
|
} catch(e) {
|
||||||
let channel = channelService.getChannel(teamCode, false);
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
|
||||||
await handleComBtlProgress(myTeam, this.app.get('robotHurtTimer'), teamMap, channel); // 结算
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import { RankFirstType } from '../../../db/RankFirst';
|
|||||||
import { LotType } from '../../../db/Lot';
|
import { LotType } from '../../../db/Lot';
|
||||||
import { _checkFilterWords, getTire, taflush } from '../../../services/sdkService';
|
import { _checkFilterWords, getTire, taflush } from '../../../services/sdkService';
|
||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -55,14 +56,18 @@ export class ChatRemote {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async addWorldChannel(roleId: string, serverId: number, sid: string, flag: boolean = true) {
|
public async addWorldChannel(roleId: string, serverId: number, sid: string, flag: boolean = true) {
|
||||||
const name = `world${serverId}`;
|
try {
|
||||||
let channel = this.channelService.getChannel(name, flag);
|
const name = `world${serverId}`;
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(name, flag);
|
||||||
channel.add(roleId, sid);
|
if (!channel) return;
|
||||||
let param = {
|
channel.add(roleId, sid);
|
||||||
roleId
|
let param = {
|
||||||
};
|
roleId
|
||||||
return this.getWorldChannel(name);
|
};
|
||||||
|
return this.getWorldChannel(name);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,12 +100,16 @@ export class ChatRemote {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async kickWorldChannel(roleId: string, sid: string, serverId: number) {
|
public async kickWorldChannel(roleId: string, sid: string, serverId: number) {
|
||||||
const name = `world${serverId}`;
|
try {
|
||||||
|
const name = `world${serverId}`;
|
||||||
let channel = this.channelService.getChannel(name, false);
|
|
||||||
// leave channel
|
let channel = this.channelService.getChannel(name, false);
|
||||||
if (!channel) return;
|
// leave channel
|
||||||
channel.leave(roleId, sid);
|
if (!channel) return;
|
||||||
|
channel.leave(roleId, sid);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,12 +119,16 @@ export class ChatRemote {
|
|||||||
* @param param 信息
|
* @param param 信息
|
||||||
*/
|
*/
|
||||||
public async sendWorldMessage(serverId: number, param: any) {
|
public async sendWorldMessage(serverId: number, param: any) {
|
||||||
const name = `world${serverId}`;
|
try {
|
||||||
|
const name = `world${serverId}`;
|
||||||
let channel = this.channelService.getChannel(name, false);
|
|
||||||
// leave channel
|
let channel = this.channelService.getChannel(name, false);
|
||||||
if (!!channel) {
|
// leave channel
|
||||||
channel.pushMessage('onWorldMessage', resResult(STATUS.SUCCESS, param));
|
if (!!channel) {
|
||||||
|
channel.pushMessage('onWorldMessage', resResult(STATUS.SUCCESS, param));
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,9 +140,13 @@ export class ChatRemote {
|
|||||||
* @memberof ChatRemote
|
* @memberof ChatRemote
|
||||||
*/
|
*/
|
||||||
public async addChannel(channelName: string, roleId: string, sid: string) {
|
public async addChannel(channelName: string, roleId: string, sid: string) {
|
||||||
let channel = this.channelService.getChannel(channelName, true);
|
try {
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(channelName, true);
|
||||||
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
if (!channel) return;
|
||||||
|
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,10 +157,14 @@ export class ChatRemote {
|
|||||||
* @memberof ChatRemote
|
* @memberof ChatRemote
|
||||||
*/
|
*/
|
||||||
public async leaveChannel(channelName: string, roleId: string, sid: string) {
|
public async leaveChannel(channelName: string, roleId: string, sid: string) {
|
||||||
let channel = this.channelService.getChannel(channelName, false);
|
try {
|
||||||
// leave channel
|
let channel = this.channelService.getChannel(channelName, false);
|
||||||
if (!channel) return;
|
// leave channel
|
||||||
channel.leave(roleId, sid);
|
if (!channel) return;
|
||||||
|
channel.leave(roleId, sid);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,10 +173,14 @@ export class ChatRemote {
|
|||||||
* @memberof ChatRemote
|
* @memberof ChatRemote
|
||||||
*/
|
*/
|
||||||
public async sendGroupMsg(roomId: string, msg: Partial<GroupMessageType>) {
|
public async sendGroupMsg(roomId: string, msg: Partial<GroupMessageType>) {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
try {
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
const roleInfo = await getSimpleRoleInfo(msg.roleId);
|
if (!channel) return;
|
||||||
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msg, roleInfo }));
|
const roleInfo = await getSimpleRoleInfo(msg.roleId);
|
||||||
|
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msg, roleInfo }));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +189,11 @@ export class ChatRemote {
|
|||||||
* @memberof ChatRemote
|
* @memberof ChatRemote
|
||||||
*/
|
*/
|
||||||
public async sendPrivateMsg(msg: Partial<PrivateMessageType>) {
|
public async sendPrivateMsg(msg: Partial<PrivateMessageType>) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,10 +201,14 @@ export class ChatRemote {
|
|||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public async sendGuildActivityEnd(serverId: number) {
|
public async sendGuildActivityEnd(serverId: number) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, {}));
|
if (!channel) return;
|
||||||
|
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, {}));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,10 +216,14 @@ export class ChatRemote {
|
|||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public async sendRaceActivityStart(serverId: number) {
|
public async sendRaceActivityStart(serverId: number) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
channel.pushMessage(this.RACE_ACTIVITY_START, resResult(STATUS.SUCCESS, {}));
|
if (!channel) return;
|
||||||
|
channel.pushMessage(this.RACE_ACTIVITY_START, resResult(STATUS.SUCCESS, {}));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,18 +231,26 @@ export class ChatRemote {
|
|||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public async sendRankTopUpdated(serverId: number, ranks: (RankFirstType & {status: number})[]) {
|
public async sendRankTopUpdated(serverId: number, ranks: (RankFirstType & {status: number})[]) {
|
||||||
|
try {
|
||||||
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if (!channel) return;
|
||||||
|
channel.pushMessage(this.RANK_TOP_UPDATE, resResult(STATUS.SUCCESS, { ranks }));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
|
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
|
||||||
if (!channel) return;
|
|
||||||
channel.pushMessage(this.RANK_TOP_UPDATE, resResult(STATUS.SUCCESS, { ranks }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -214,11 +259,15 @@ export class ChatRemote {
|
|||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public async sendGuildActivityUpdate(serverId: number) {
|
public async sendGuildActivityUpdate(serverId: number) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
let guildActivities = getAllGuildActivityStatus();
|
if (!channel) return;
|
||||||
channel.pushMessage(this.GUILD_ACTIVITY_STATUS_UPDATE, resResult(STATUS.SUCCESS, { guildActivities }));
|
let guildActivities = getAllGuildActivityStatus();
|
||||||
|
channel.pushMessage(this.GUILD_ACTIVITY_STATUS_UPDATE, resResult(STATUS.SUCCESS, { guildActivities }));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,10 +277,14 @@ export class ChatRemote {
|
|||||||
* @param mails 邮件内容
|
* @param mails 邮件内容
|
||||||
*/
|
*/
|
||||||
public async sendMail(serverId: number, path: string, data: { mails: MailParam[] }) {
|
public async sendMail(serverId: number, path: string, data: { mails: MailParam[] }) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if (!channel) return;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
channel.pushMessage(path, resResult(STATUS.SUCCESS, data));
|
if (!channel) return;
|
||||||
|
channel.pushMessage(path, resResult(STATUS.SUCCESS, data));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,21 +292,29 @@ export class ChatRemote {
|
|||||||
* @param serverId
|
* @param serverId
|
||||||
*/
|
*/
|
||||||
public async sendServerMaintenance(serverId: number) {
|
public async sendServerMaintenance(serverId: number) {
|
||||||
|
try {
|
||||||
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if (!channel) return { result: false, serverId };
|
||||||
|
channel.pushMessage('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE));
|
||||||
|
return { result: true, serverId };
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
|
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
|
||||||
if (!channel) return { result: false, serverId };
|
|
||||||
channel.pushMessage('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE));
|
|
||||||
return { result: true, serverId };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pushCurrentTime(serverId: number, time: number) {
|
public async pushCurrentTime(serverId: number, time: number) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if (!channel) return { result: false, serverId };
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if (!channel) return { result: false, serverId };
|
||||||
channel.pushMessage('onPushCurrentTime', resResult(STATUS.SUCCESS, { time }));
|
|
||||||
return { result: true, serverId };
|
channel.pushMessage('onPushCurrentTime', resResult(STATUS.SUCCESS, { time }));
|
||||||
|
return { result: true, serverId };
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,49 +322,81 @@ export class ChatRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public async sendGuildAuction(guildCode: string, lot: LotType) {
|
public async sendGuildAuction(guildCode: string, lot: LotType) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||||
if(!channel) return false;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if(!channel) return false;
|
||||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
|
||||||
return true;
|
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendWorldAuction(serverId: number, lot: LotType) {
|
public async sendWorldAuction(serverId: number, lot: LotType) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if(!channel) return false;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if(!channel) return false;
|
||||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
|
||||||
return true;
|
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendAuctionUpdate(serverId: number, params: { lots: LotType[] }) {
|
public async sendAuctionUpdate(serverId: number, params: { lots: LotType[] }) {
|
||||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
try {
|
||||||
let channel = this.channelService.getChannel(roomId, false);
|
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||||
if(!channel) return false;
|
let channel = this.channelService.getChannel(roomId, false);
|
||||||
|
if(!channel) return false;
|
||||||
channel.pushMessage('onAuctionUpdate', resResult(STATUS.SUCCESS, params));
|
|
||||||
return true;
|
channel.pushMessage('onAuctionUpdate', resResult(STATUS.SUCCESS, params));
|
||||||
|
return true;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async checkFilterWords(word: string) {
|
public async checkFilterWords(word: string) {
|
||||||
return await _checkFilterWords(word);
|
try {
|
||||||
|
return await _checkFilterWords(word);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { pick } from 'underscore';
|
|||||||
import { LotType } from '../../../db/Lot';
|
import { LotType } from '../../../db/Lot';
|
||||||
import { DividendType } from '../../../db/Dividend';
|
import { DividendType } from '../../../db/Dividend';
|
||||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -130,14 +131,18 @@ export class GuildRemote {
|
|||||||
* @param sid 玩家sid
|
* @param sid 玩家sid
|
||||||
*/
|
*/
|
||||||
public memberQuit(guildCode: string, roleId: string, guild: GuildType, sid?: string) {
|
public memberQuit(guildCode: string, roleId: string, guild: GuildType, sid?: string) {
|
||||||
// 被踢出公会
|
try {
|
||||||
this.pushMessageByUids(guildCode, this.MEMBER_QUIT, roleId, {
|
// 被踢出公会
|
||||||
code: guildCode,
|
this.pushMessageByUids(guildCode, this.MEMBER_QUIT, roleId, {
|
||||||
roleId
|
code: guildCode,
|
||||||
}, sid);
|
roleId
|
||||||
// 更新人数减少
|
}, sid);
|
||||||
this.updateInfo(guildCode, { memberCnt: guild.memberCnt, guildCe: guild.guildCe });
|
// 更新人数减少
|
||||||
leaveGuildChannel(roleId, sid, guildCode);
|
this.updateInfo(guildCode, { memberCnt: guild.memberCnt, guildCe: guild.guildCe });
|
||||||
|
leaveGuildChannel(roleId, sid, guildCode);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,9 +150,13 @@ export class GuildRemote {
|
|||||||
* @param guildCode 军团code
|
* @param guildCode 军团code
|
||||||
*/
|
*/
|
||||||
public dismiss(guildCode: string) {
|
public dismiss(guildCode: string) {
|
||||||
let channel = this.pushMessage(guildCode, this.DISMISS, { code: guildCode });
|
try {
|
||||||
if (!!channel) {
|
let channel = this.pushMessage(guildCode, this.DISMISS, { code: guildCode });
|
||||||
channel.destroy();
|
if (!!channel) {
|
||||||
|
channel.destroy();
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +166,11 @@ export class GuildRemote {
|
|||||||
* @param info 军团相关信息
|
* @param info 军团相关信息
|
||||||
*/
|
*/
|
||||||
public updateInfo(guildCode: string, info: any) {
|
public updateInfo(guildCode: string, info: any) {
|
||||||
this.pushMessage(guildCode, this.GUILD_INFO_UPDATE, info);
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_INFO_UPDATE, info);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,7 +187,7 @@ export class GuildRemote {
|
|||||||
this.demotion(guildCode, oldLeaderId);
|
this.demotion(guildCode, oldLeaderId);
|
||||||
this.promotion(guildCode, roleId);
|
this.promotion(guildCode, roleId);
|
||||||
}catch(e) {
|
}catch(e) {
|
||||||
console.log(e.stack)
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,9 +197,13 @@ export class GuildRemote {
|
|||||||
* @param roleId 旧团长id
|
* @param roleId 旧团长id
|
||||||
*/
|
*/
|
||||||
public demotion(guildCode: string, roleId: string) {
|
public demotion(guildCode: string, roleId: string) {
|
||||||
this.pushMessageByUids(guildCode, this.DEMOTION, roleId, {
|
try {
|
||||||
code: guildCode
|
this.pushMessageByUids(guildCode, this.DEMOTION, roleId, {
|
||||||
});
|
code: guildCode
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,9 +212,13 @@ export class GuildRemote {
|
|||||||
* @param roleId 新团长id
|
* @param roleId 新团长id
|
||||||
*/
|
*/
|
||||||
public promotion(guildCode: string, roleId: string) {
|
public promotion(guildCode: string, roleId: string) {
|
||||||
this.pushMessageByUids(guildCode, this.PROMOTION, roleId, {
|
try {
|
||||||
code: guildCode
|
this.pushMessageByUids(guildCode, this.PROMOTION, roleId, {
|
||||||
});
|
code: guildCode
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,8 +226,12 @@ export class GuildRemote {
|
|||||||
* @param guildRecType 动态
|
* @param guildRecType 动态
|
||||||
*/
|
*/
|
||||||
public addRec(guildRecType: GuildRecType) {
|
public addRec(guildRecType: GuildRecType) {
|
||||||
let { guildCode, type, params, createTime } = guildRecType;
|
try {
|
||||||
this.pushMessage(guildCode, this.GUILD_REC_ADD, { type, params, createTime });
|
let { guildCode, type, params, createTime } = guildRecType;
|
||||||
|
this.pushMessage(guildCode, this.GUILD_REC_ADD, { type, params, createTime });
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +239,11 @@ export class GuildRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public pushGateHp(guildCode: string, gateHp: number) {
|
public pushGateHp(guildCode: string, gateHp: number) {
|
||||||
this.pushMessage(guildCode, this.GUILD_GATE_ACT_HP, { gateHp });
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_GATE_ACT_HP, { gateHp });
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,7 +251,11 @@ export class GuildRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public pushRank(guildCode: string, msg: GuildRankParams) {
|
public pushRank(guildCode: string, msg: GuildRankParams) {
|
||||||
this.pushMessage(guildCode, this.GATE_ACT_RANK, msg);
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GATE_ACT_RANK, msg);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,7 +263,11 @@ export class GuildRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public pushCityActRank(guildCode: string, msg: GuildRankParams) {
|
public pushCityActRank(guildCode: string, msg: GuildRankParams) {
|
||||||
this.pushMessage(guildCode, this.CITY_ACT_RANK, msg);
|
try {
|
||||||
|
this.pushMessage(guildCode, this.CITY_ACT_RANK, msg);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,8 +275,12 @@ export class GuildRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public async sendGuildActivityEnd(guildCode: string) {
|
public async sendGuildActivityEnd(guildCode: string) {
|
||||||
console.log("MSG END")
|
try {
|
||||||
this.pushMessage(guildCode, this.GUILD_ACTIVITY_END, {});
|
console.log("MSG END")
|
||||||
|
this.pushMessage(guildCode, this.GUILD_ACTIVITY_END, {});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,16 +290,20 @@ export class GuildRemote {
|
|||||||
* @param declareCount 宣战数量
|
* @param declareCount 宣战数量
|
||||||
*/
|
*/
|
||||||
public async sendGuildCityDeclare(cityId: number, declareGuildCode: string, declareCount: number) {
|
public async sendGuildCityDeclare(cityId: number, declareGuildCode: string, declareCount: number) {
|
||||||
this.pushMessageToCity(cityId, this.GUILD_CITY_DECLARE, {
|
try {
|
||||||
cityId,
|
this.pushMessageToCity(cityId, this.GUILD_CITY_DECLARE, {
|
||||||
declareGuildCode,
|
cityId,
|
||||||
declareCount
|
declareGuildCode,
|
||||||
});
|
declareCount
|
||||||
this.pushMessage(declareGuildCode, this.GUILD_CITY_DECLARE, {
|
});
|
||||||
cityId,
|
this.pushMessage(declareGuildCode, this.GUILD_CITY_DECLARE, {
|
||||||
declareGuildCode,
|
cityId,
|
||||||
declareCount
|
declareGuildCode,
|
||||||
});
|
declareCount
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,10 +312,14 @@ export class GuildRemote {
|
|||||||
* @param gateHp 血条
|
* @param gateHp 血条
|
||||||
*/
|
*/
|
||||||
public async pushCityGateHp(cityId: number, gateHp: number) {
|
public async pushCityGateHp(cityId: number, gateHp: number) {
|
||||||
this.pushMessageToCity(cityId, this.GUILD_CITY_ACT_HP, {
|
try {
|
||||||
cityId,
|
this.pushMessageToCity(cityId, this.GUILD_CITY_ACT_HP, {
|
||||||
gateHp
|
cityId,
|
||||||
});
|
gateHp
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,12 +329,16 @@ export class GuildRemote {
|
|||||||
* @param ranks 军团排名和自己所在的排名
|
* @param ranks 军团排名和自己所在的排名
|
||||||
*/
|
*/
|
||||||
public async pushRaceHorseUpdate(guildCode: string, woodenHorseList: WoodenHorse[], ranks: GuildRankParams, events: Event[]) {
|
public async pushRaceHorseUpdate(guildCode: string, woodenHorseList: WoodenHorse[], ranks: GuildRankParams, events: Event[]) {
|
||||||
this.pushMessage(guildCode, this.GUILD_RACE_UPDATE, {
|
try {
|
||||||
timestamp: Date.now(),
|
this.pushMessage(guildCode, this.GUILD_RACE_UPDATE, {
|
||||||
woodenHorseList,
|
timestamp: Date.now(),
|
||||||
...ranks,
|
woodenHorseList,
|
||||||
events
|
...ranks,
|
||||||
});
|
events
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -295,10 +348,14 @@ export class GuildRemote {
|
|||||||
* @param woodenHorse 木马
|
* @param woodenHorse 木马
|
||||||
*/
|
*/
|
||||||
public async pushRaceHorseJoin(guildCode: string, woodenHorse: WoodenHorse) {
|
public async pushRaceHorseJoin(guildCode: string, woodenHorse: WoodenHorse) {
|
||||||
this.pushMessage(guildCode, this.GUILD_RACE_JOIN, {
|
try {
|
||||||
timestamp: Date.now(),
|
this.pushMessage(guildCode, this.GUILD_RACE_JOIN, {
|
||||||
woodenHorse
|
timestamp: Date.now(),
|
||||||
});
|
woodenHorse
|
||||||
|
});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,7 +363,11 @@ export class GuildRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public async sendRaceEvent(guildCode: string, events: Event[]) {
|
public async sendRaceEvent(guildCode: string, events: Event[]) {
|
||||||
this.pushMessage(guildCode, this.GUILD_RACE_EVENT, { timestamp: Date.now(), events });
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_RACE_EVENT, { timestamp: Date.now(), events });
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -317,7 +378,11 @@ export class GuildRemote {
|
|||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
public async pushBossStatus(guildCode: string, result: any) {
|
public async pushBossStatus(guildCode: string, result: any) {
|
||||||
this.pushMessage(guildCode, this.GUILD_BOSS_OPEN, pick(result, ['status', 'bossInfo', 'leaderOpenCnt']));
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_BOSS_OPEN, pick(result, ['status', 'bossInfo', 'leaderOpenCnt']));
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,8 +390,12 @@ export class GuildRemote {
|
|||||||
* @param guildCode
|
* @param guildCode
|
||||||
*/
|
*/
|
||||||
public async sendPopUpActivity(guildCode: string, data: any[]) {
|
public async sendPopUpActivity(guildCode: string, data: any[]) {
|
||||||
console.log("sendPopUpActivity")
|
try {
|
||||||
this.pushMessage(guildCode, this.GUILD_POP_UP_ACTIVITY, data);
|
console.log("sendPopUpActivity")
|
||||||
|
this.pushMessage(guildCode, this.GUILD_POP_UP_ACTIVITY, data);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -336,24 +405,44 @@ export class GuildRemote {
|
|||||||
* @param data 军团内容
|
* @param data 军团内容
|
||||||
*/
|
*/
|
||||||
public async sendMailToGuild(guildCode: string, path: string, data: { mails: MailParam[] }) {
|
public async sendMailToGuild(guildCode: string, path: string, data: { mails: MailParam[] }) {
|
||||||
this.pushMessage(guildCode, path, data);
|
try {
|
||||||
|
this.pushMessage(guildCode, path, data);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendTrainReset(guildCode: string) {
|
public async sendTrainReset(guildCode: string) {
|
||||||
this.pushMessage(guildCode, this.GUILD_TRAIN_RESET, {});
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_TRAIN_RESET, {});
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pushEncourage(guildCode: string, param: {encourageCnt: number; encourageMax: number; myEncourageCnt: number;}) {
|
public async pushEncourage(guildCode: string, param: {encourageCnt: number; encourageMax: number; myEncourageCnt: number;}) {
|
||||||
this.pushMessage(guildCode, this.GUILD_BOSS_ENCOURAGE, param);
|
try {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_BOSS_ENCOURAGE, param);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
public async pushAuctionUpdate(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||||
if(param.lots) this.pushMessage(guildCode, this.AUCTION_UPDATE, { lots: param.lots });
|
try {
|
||||||
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_UPDATE, { dividends: param.dividends });
|
if(param.lots) this.pushMessage(guildCode, this.AUCTION_UPDATE, { lots: param.lots });
|
||||||
|
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_UPDATE, { dividends: param.dividends });
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pushAuctionAdd(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
public async pushAuctionAdd(guildCode: string, param: { lots: LotType[]; dividends: DividendType[] }) {
|
||||||
if(param.lots) this.pushMessage(guildCode, this.AUCTION_ADD, { lots: param.lots });
|
try {
|
||||||
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_ADD, { dividends: param.dividends });
|
if(param.lots) this.pushMessage(guildCode, this.AUCTION_ADD, { lots: param.lots });
|
||||||
|
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_ADD, { dividends: param.dividends });
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
|||||||
import { setDicAuctionTime } from '../../../services/guildActivityService';
|
import { setDicAuctionTime } from '../../../services/guildActivityService';
|
||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
import { taflush } from '../../../services/sdkService';
|
import { taflush } from '../../../services/sdkService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
return new ConnectorRemote(app);
|
return new ConnectorRemote(app);
|
||||||
@@ -21,46 +22,62 @@ export class ConnectorRemote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async remoteLogin(uid: string, message?: any) {
|
public async remoteLogin(uid: string, message?: any) {
|
||||||
await kickUser(this.app, uid, message);
|
try {
|
||||||
|
await kickUser(this.app, uid, message);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setOtherUserGuildSession(params: { roleId: string, userGuild: UserGuildType}[]) {
|
public async setOtherUserGuildSession(params: { roleId: string, userGuild: UserGuildType}[]) {
|
||||||
let sessionService = this.app.get('sessionService');
|
try {
|
||||||
for(let {roleId, userGuild} of params) {
|
let sessionService = this.app.get('sessionService');
|
||||||
let sessions = sessionService.getByUid(roleId);
|
for(let {roleId, userGuild} of params) {
|
||||||
if(!!sessions) {
|
let sessions = sessionService.getByUid(roleId);
|
||||||
sessions.forEach(session => {
|
if(!!sessions) {
|
||||||
if(userGuild && userGuild.status == 1) {
|
sessions.forEach(session => {
|
||||||
sessionService.aimportAll(session.id, { guildCode: userGuild?.guildCode, guildAuth: userGuild?.auth });
|
if(userGuild && userGuild.status == 1) {
|
||||||
} else {
|
sessionService.aimportAll(session.id, { guildCode: userGuild?.guildCode, guildAuth: userGuild?.auth });
|
||||||
sessionService.aimportAll(session.id, { guildCode: '', guildAuth: 0 });
|
} else {
|
||||||
}
|
sessionService.aimportAll(session.id, { guildCode: '', guildAuth: 0 });
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setOtherUserRoleNameSession(params: { roleId: string, roleName: string}[]) {
|
public async setOtherUserRoleNameSession(params: { roleId: string, roleName: string}[]) {
|
||||||
let sessionService = this.app.get('sessionService');
|
try {
|
||||||
for(let {roleId, roleName} of params) {
|
let sessionService = this.app.get('sessionService');
|
||||||
let sessions = sessionService.getByUid(roleId);
|
for(let {roleId, roleName} of params) {
|
||||||
if(!!sessions) {
|
let sessions = sessionService.getByUid(roleId);
|
||||||
sessions.forEach(session => {
|
if(!!sessions) {
|
||||||
sessionService.aimportAll(session.id, { roleName });
|
sessions.forEach(session => {
|
||||||
});
|
sessionService.aimportAll(session.id, { roleName });
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setOtherUseBlockTypeSession(params: { roleId: string, blockType: string}[]) {
|
public async setOtherUseBlockTypeSession(params: { roleId: string, blockType: string}[]) {
|
||||||
let sessionService = this.app.get('sessionService');
|
try {
|
||||||
for(let {roleId, blockType} of params) {
|
let sessionService = this.app.get('sessionService');
|
||||||
let sessions = sessionService.getByUid(roleId);
|
for(let {roleId, blockType} of params) {
|
||||||
if(!!sessions) {
|
let sessions = sessionService.getByUid(roleId);
|
||||||
sessions.forEach(session => {
|
if(!!sessions) {
|
||||||
sessionService.aimportAll(session.id, { blockType });
|
sessions.forEach(session => {
|
||||||
});
|
sessionService.aimportAll(session.id, { blockType });
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,41 +85,73 @@ export class ConnectorRemote {
|
|||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setPvpSeasonNum(pvpConfig: PVPConfigType) {
|
public setPvpSeasonNum(pvpConfig: PVPConfigType) {
|
||||||
if(pvpConfig) {
|
try {
|
||||||
this.app.set('pvpSeasonNum', pvpConfig.seasonNum);
|
if(pvpConfig) {
|
||||||
this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
|
this.app.set('pvpSeasonNum', pvpConfig.seasonNum);
|
||||||
|
this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initPvpSeasonNum() {
|
public async initPvpSeasonNum() {
|
||||||
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
|
try {
|
||||||
this.setPvpSeasonNum(pvpConfig);
|
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
|
||||||
|
this.setPvpSeasonNum(pvpConfig);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 改变字典表中的拍卖行时间
|
* 改变字典表中的拍卖行时间
|
||||||
*/
|
*/
|
||||||
async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) {
|
async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) {
|
||||||
setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld);
|
try {
|
||||||
|
setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { sendAllGuildRanks, sendGuildActEndMsg, calWoodenHorseAndSend, sendRaceS
|
|||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
import { setWeek } from '../../../pubUtils/timeUtil';
|
import { setWeek } from '../../../pubUtils/timeUtil';
|
||||||
import { sendUngotDividend } from '../../../services/auctionService';
|
import { sendUngotDividend } from '../../../services/auctionService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -24,47 +25,67 @@ export class GuildActivityRemote {
|
|||||||
* 从systimer服分发到guild各个服,发送排行榜数据
|
* 从systimer服分发到guild各个服,发送排行榜数据
|
||||||
*/
|
*/
|
||||||
public async sendRankToGuilds(aid: number) {
|
public async sendRankToGuilds(aid: number) {
|
||||||
await sendAllGuildRanks(aid);
|
try {
|
||||||
|
await sendAllGuildRanks(aid);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送结束活动消息
|
* 发送结束活动消息
|
||||||
*/
|
*/
|
||||||
public async guildActivityEnd(aid: number) {
|
public async guildActivityEnd(aid: number) {
|
||||||
await sendGuildActEndMsg(aid);
|
try {
|
||||||
|
await sendGuildActEndMsg(aid);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算粮草先行木马状态并发送
|
* 计算粮草先行木马状态并发送
|
||||||
*/
|
*/
|
||||||
public async calWoodenHorseAndSend(serverId: number) {
|
public async calWoodenHorseAndSend(serverId: number) {
|
||||||
await calWoodenHorseAndSend(serverId);
|
try {
|
||||||
|
await calWoodenHorseAndSend(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送粮草先行活动开始通知
|
* 发送粮草先行活动开始通知
|
||||||
*/
|
*/
|
||||||
async raceActivityStart(serverId: number) {
|
async raceActivityStart(serverId: number) {
|
||||||
await sendRaceStartMsg(serverId);
|
try {
|
||||||
|
await sendRaceStartMsg(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* !! 注意,这条函数会改变内存中的字典表,影响甚大,请考虑清楚后使用
|
* !! 注意,这条函数会改变内存中的字典表,影响甚大,请考虑清楚后使用
|
||||||
*/
|
*/
|
||||||
async updateGuildActivityData(aid: number, isStart: boolean) {
|
async updateGuildActivityData(aid: number, isStart: boolean) {
|
||||||
let guildActivity = gameData.guildActivity;
|
try {
|
||||||
let cur = guildActivity.get(aid);
|
let guildActivity = gameData.guildActivity;
|
||||||
|
let cur = guildActivity.get(aid);
|
||||||
if (isStart) {
|
|
||||||
let now = new Date();
|
if (isStart) {
|
||||||
cur.startMinute = now.getMinutes();
|
let now = new Date();
|
||||||
cur.startTime = now.getHours();
|
cur.startMinute = now.getMinutes();
|
||||||
cur.startSeconds = now.getSeconds();
|
cur.startTime = now.getHours();
|
||||||
} else {
|
cur.startSeconds = now.getSeconds();
|
||||||
let now = new Date(Date.now() - cur.duringTime * 1000);
|
} else {
|
||||||
cur.startMinute = now.getMinutes();
|
let now = new Date(Date.now() - cur.duringTime * 1000);
|
||||||
cur.startTime = now.getHours();
|
cur.startMinute = now.getMinutes();
|
||||||
cur.startSeconds = now.getSeconds();
|
cur.startTime = now.getHours();
|
||||||
|
cur.startSeconds = now.getSeconds();
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,33 +96,57 @@ export class GuildActivityRemote {
|
|||||||
* @param {number} endSeconds 从开始之后几秒后结束活动
|
* @param {number} endSeconds 从开始之后几秒后结束活动
|
||||||
*/
|
*/
|
||||||
async setDicGuildActivity(now: number, aid: number, startSeconds: number, endSeconds: number) {
|
async setDicGuildActivity(now: number, aid: number, startSeconds: number, endSeconds: number) {
|
||||||
return setDicGuildActivity(now, aid, startSeconds, endSeconds);
|
try {
|
||||||
|
return setDicGuildActivity(now, aid, startSeconds, endSeconds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 改变字典表中的拍卖行时间
|
* 改变字典表中的拍卖行时间
|
||||||
*/
|
*/
|
||||||
async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) {
|
async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) {
|
||||||
setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld);
|
try {
|
||||||
|
setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* !! 注意,这条函数会改变内存时间,影响甚大,请考虑清楚后使用
|
* !! 注意,这条函数会改变内存时间,影响甚大,请考虑清楚后使用
|
||||||
*/
|
*/
|
||||||
async setDay(week: number) {
|
async setDay(week: number) {
|
||||||
setWeek(week);
|
try {
|
||||||
|
setWeek(week);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentTime(time: number) {
|
setCurrentTime(time: number) {
|
||||||
this.currentTime = time;
|
try {
|
||||||
this.setTime = Date.now();
|
this.currentTime = time;
|
||||||
|
this.setTime = Date.now();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentTime() {
|
getCurrentTime() {
|
||||||
return Date.now() - this.setTime + this.currentTime;
|
try {
|
||||||
|
return Date.now() - this.setTime + this.currentTime;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendUngotDividend() {
|
public async sendUngotDividend() {
|
||||||
await sendUngotDividend();
|
try {
|
||||||
|
await sendUngotDividend();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ import { Application, ChannelService, HandlerService, } from 'pinus';
|
|||||||
import { reloadResources } from '../../../pubUtils/data';
|
import { reloadResources } from '../../../pubUtils/data';
|
||||||
import { taflush, treatGuildName } from '../../../services/sdkService';
|
import { taflush, treatGuildName } from '../../../services/sdkService';
|
||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -21,26 +22,50 @@ export class GuildRemote {
|
|||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async treatGuildName(content: string) {
|
public async treatGuildName(content: string) {
|
||||||
await treatGuildName(content);
|
try {
|
||||||
|
await treatGuildName(content);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ import { reloadResources } from '../../../pubUtils/data';
|
|||||||
import { settleOrderFromRedisPub } from '../../../services/orderService';
|
import { settleOrderFromRedisPub } from '../../../services/orderService';
|
||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
import { taflush } from '../../../services/sdkService';
|
import { taflush } from '../../../services/sdkService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -22,26 +23,50 @@ export class OrderRemote {
|
|||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async settleOrderFromRedisPub(message: string) {
|
public async settleOrderFromRedisPub(message: string) {
|
||||||
await settleOrderFromRedisPub(message);
|
try {
|
||||||
|
await settleOrderFromRedisPub(message);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import { getDefaultRoleInfo } from '../../../services/roleService';
|
|||||||
import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
||||||
import { treatRoleName, taflush } from '../../../services/sdkService';
|
import { treatRoleName, taflush } from '../../../services/sdkService';
|
||||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
new HandlerService(app, {});
|
new HandlerService(app, {});
|
||||||
@@ -46,64 +47,93 @@ export class RoleRemote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setRankFirst(rank: RankFirstType) {
|
public setRankFirst(rank: RankFirstType) {
|
||||||
// console.log('****** setRankFirst', rank.serverId, rank.id, rank)
|
try {
|
||||||
if(!this.rankFirstRewards.has(rank.serverId)) {
|
// console.log('****** setRankFirst', rank.serverId, rank.id, rank)
|
||||||
this.rankFirstRewards.set(rank.serverId, new Map());
|
if(!this.rankFirstRewards.has(rank.serverId)) {
|
||||||
|
this.rankFirstRewards.set(rank.serverId, new Map());
|
||||||
|
}
|
||||||
|
this.rankFirstRewards.get(rank.serverId).set(rank.id, rank);
|
||||||
|
this.app.set('rankFirstRewards', this.rankFirstRewards);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
this.rankFirstRewards.get(rank.serverId).set(rank.id, rank);
|
|
||||||
this.app.set('rankFirstRewards', this.rankFirstRewards);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRankFirstById(serverId: number, id: number) {
|
public getRankFirstById(serverId: number, id: number) {
|
||||||
return this.rankFirstRewards.get(serverId)?.get(id);
|
try {
|
||||||
|
return this.rankFirstRewards.get(serverId)?.get(id);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setInitRole() {
|
public setInitRole() {
|
||||||
let result = getInitRoleInfo();
|
try {
|
||||||
let { role, heroes, skins, figureInfo } = result;
|
let result = getInitRoleInfo();
|
||||||
for(let hero of heroes) {
|
let { role, heroes, skins, figureInfo } = result;
|
||||||
this.initHeroes.set(hero.hid, hero);
|
for(let hero of heroes) {
|
||||||
|
this.initHeroes.set(hero.hid, hero);
|
||||||
|
}
|
||||||
|
for(let skin of skins) {
|
||||||
|
this.initSkins.set(skin.hid, skin);
|
||||||
|
}
|
||||||
|
this.initRole = role;
|
||||||
|
this.figureInfo = figureInfo;
|
||||||
|
const initRoleInfos = getDefaultRoleInfo(this.initHeroes, this.initSkins, this.initRole, this.figureInfo);
|
||||||
|
this.app.set('initRoleInfos', initRoleInfos);
|
||||||
|
this.app.set('initHeroes', this.initHeroes);
|
||||||
|
this.app.set('initSkins', this.initSkins);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
for(let skin of skins) {
|
|
||||||
this.initSkins.set(skin.hid, skin);
|
|
||||||
}
|
|
||||||
this.initRole = role;
|
|
||||||
this.figureInfo = figureInfo;
|
|
||||||
const initRoleInfos = getDefaultRoleInfo(this.initHeroes, this.initSkins, this.initRole, this.figureInfo);
|
|
||||||
this.app.set('initRoleInfos', initRoleInfos);
|
|
||||||
this.app.set('initHeroes', this.initHeroes);
|
|
||||||
this.app.set('initSkins', this.initSkins);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getInitRoleInfos() {
|
public getInitRoleInfos() {
|
||||||
let initRoleInfos = this.app.get('initRoleInfos');
|
try {
|
||||||
if (!initRoleInfos) {
|
let initRoleInfos = this.app.get('initRoleInfos');
|
||||||
initRoleInfos = getDefaultRoleInfo(this.initHeroes, this.initSkins, this.initRole, this.figureInfo);
|
if (!initRoleInfos) {
|
||||||
this.app.set('initRoleInfos', initRoleInfos);
|
initRoleInfos = getDefaultRoleInfo(this.initHeroes, this.initSkins, this.initRole, this.figureInfo);
|
||||||
|
this.app.set('initRoleInfos', initRoleInfos);
|
||||||
|
}
|
||||||
|
return initRoleInfos;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
return initRoleInfos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getInitHeroes() {
|
public getInitHeroes() {
|
||||||
let result: HeroUpdate[] = [];
|
try {
|
||||||
for(let hid of DEFAULT_HEROES) {
|
let result: HeroUpdate[] = [];
|
||||||
result.push(this.initHeroes.get(hid));
|
for(let hid of DEFAULT_HEROES) {
|
||||||
|
result.push(this.initHeroes.get(hid));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getInitSkins() {
|
public getInitSkins() {
|
||||||
let result: SkinUpdate[] = [];
|
try {
|
||||||
for(let hid of DEFAULT_HEROES) {
|
let result: SkinUpdate[] = [];
|
||||||
result.push(this.initSkins.get(hid));
|
for(let hid of DEFAULT_HEROES) {
|
||||||
|
result.push(this.initSkins.get(hid));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getInitHeroById(hid: number) {
|
public getInitHeroById(hid: number) {
|
||||||
return {
|
try {
|
||||||
heroInfo: this.initHeroes.get(hid),
|
return {
|
||||||
skinInfo: this.initSkins.get(hid)
|
heroInfo: this.initHeroes.get(hid),
|
||||||
|
skinInfo: this.initSkins.get(hid)
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,39 +142,71 @@ export class RoleRemote {
|
|||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public setPvpSeasonNum(pvpConfig: PVPConfigType) {
|
public setPvpSeasonNum(pvpConfig: PVPConfigType) {
|
||||||
if(pvpConfig) {
|
try {
|
||||||
this.app.set('pvpSeasonNum', pvpConfig.seasonNum);
|
if(pvpConfig) {
|
||||||
this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
|
this.app.set('pvpSeasonNum', pvpConfig.seasonNum);
|
||||||
|
this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime);
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initPvpSeasonNum() {
|
public async initPvpSeasonNum() {
|
||||||
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
|
try {
|
||||||
this.setPvpSeasonNum(pvpConfig);
|
let pvpConfig = await PVPConfigModel.findCurPVPConfig();
|
||||||
|
this.setPvpSeasonNum(pvpConfig);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async treatRoleName(roleId: string) {
|
public async treatRoleName(roleId: string) {
|
||||||
await treatRoleName(roleId);
|
try {
|
||||||
|
await treatRoleName(roleId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
|
||||||
setServerMainten(serverIds, startTime, endTime);
|
try {
|
||||||
|
setServerMainten(serverIds, startTime, endTime);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public stopServerMainten(serverIds: number[]) {
|
public stopServerMainten(serverIds: number[]) {
|
||||||
stopServerMainten(serverIds);
|
try {
|
||||||
|
stopServerMainten(serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getServerMainten(serverId: number) {
|
public getServerMainten(serverId: number) {
|
||||||
return getServerMainten(serverId);
|
try {
|
||||||
|
return getServerMainten(serverId);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { ServerlistType } from '../../../db/Serverlist';
|
|||||||
import { MarqueeType } from '../../../db/Marquee';
|
import { MarqueeType } from '../../../db/Marquee';
|
||||||
import { taflush } from '../../../services/sdkService';
|
import { taflush } from '../../../services/sdkService';
|
||||||
import { RegionType } from '../../../db/Region';
|
import { RegionType } from '../../../db/Region';
|
||||||
|
import { errlogger } from '../../../util/logger';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
return new SystimerRemote(app);
|
return new SystimerRemote(app);
|
||||||
@@ -24,30 +25,54 @@ export class SystimerRemote {
|
|||||||
private channelService: ChannelService;
|
private channelService: ChannelService;
|
||||||
|
|
||||||
public async resetPvpSeasonTime(day: number) {
|
public async resetPvpSeasonTime(day: number) {
|
||||||
return await resetPvpSeasonTime(day);
|
try {
|
||||||
|
return await resetPvpSeasonTime(day);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async guildActivityStart(dicGuildActivity: DicGuildActivity) {
|
public async guildActivityStart(dicGuildActivity: DicGuildActivity) {
|
||||||
return await guildActivityStart(dicGuildActivity);
|
try {
|
||||||
|
return await guildActivityStart(dicGuildActivity);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async gateActivityEnd() {
|
public async gateActivityEnd() {
|
||||||
return await gateActivityEnd();
|
try {
|
||||||
|
return await gateActivityEnd();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cityActivityEnd() {
|
public async cityActivityEnd() {
|
||||||
return await cityActivityEnd();
|
try {
|
||||||
|
return await cityActivityEnd();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async raceActivityEnd() {
|
public async raceActivityEnd() {
|
||||||
return await raceActivityEnd();
|
try {
|
||||||
|
return await raceActivityEnd();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重载json资源
|
* 重载json资源
|
||||||
*/
|
*/
|
||||||
public async reloadResources() {
|
public async reloadResources() {
|
||||||
reloadResources();
|
try {
|
||||||
|
reloadResources();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,11 +80,19 @@ export class SystimerRemote {
|
|||||||
* @param code 跑马灯唯一code
|
* @param code 跑马灯唯一code
|
||||||
*/
|
*/
|
||||||
public async setMarquee(marquee: MarqueeType) {
|
public async setMarquee(marquee: MarqueeType) {
|
||||||
return await setMarquee(marquee);
|
try {
|
||||||
|
return await setMarquee(marquee);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async cancelMarquee(code: string) {
|
public async cancelMarquee(code: string) {
|
||||||
return await cancelMarquee(code);
|
try {
|
||||||
|
return await cancelMarquee(code);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,44 +102,80 @@ export class SystimerRemote {
|
|||||||
* @param {number} endSeconds 从开始之后几秒后结束活动
|
* @param {number} endSeconds 从开始之后几秒后结束活动
|
||||||
*/
|
*/
|
||||||
public async setDicGuildActivity(now: number, aid: number, startSeconds: number, endSeconds: number) {
|
public async setDicGuildActivity(now: number, aid: number, startSeconds: number, endSeconds: number) {
|
||||||
setDicGuildActivity(now, aid, startSeconds, endSeconds);
|
try {
|
||||||
|
setDicGuildActivity(now, aid, startSeconds, endSeconds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 改变字典表中的拍卖行时间
|
* 改变字典表中的拍卖行时间
|
||||||
*/
|
*/
|
||||||
public async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) {
|
public async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) {
|
||||||
setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld);
|
try {
|
||||||
|
setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setGuildActivitySchedule() {
|
public async setGuildActivitySchedule() {
|
||||||
await guildActivitySchedule();
|
try {
|
||||||
|
await guildActivitySchedule();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async setAuctionSchedule() {
|
public async setAuctionSchedule() {
|
||||||
auctionSchedule();
|
try {
|
||||||
|
auctionSchedule();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* !! 注意,这条函数会改变内存时间,影响甚大,请考虑清楚后使用
|
* !! 注意,这条函数会改变内存时间,影响甚大,请考虑清楚后使用
|
||||||
*/
|
*/
|
||||||
async setDay(week: number) {
|
async setDay(week: number) {
|
||||||
setWeek(week);
|
try {
|
||||||
|
setWeek(week);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initMaintenance(servers?: ServerlistType[]) {
|
public async initMaintenance(servers?: ServerlistType[]) {
|
||||||
await initMaintenance(servers);
|
try {
|
||||||
|
await initMaintenance(servers);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async stopMaintenance(batchCode: string, serverIds: number[]) {
|
public async stopMaintenance(batchCode: string, serverIds: number[]) {
|
||||||
await stopMaintenance(batchCode, serverIds);
|
try {
|
||||||
|
await stopMaintenance(batchCode, serverIds);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public taflush() {
|
public taflush() {
|
||||||
return taflush();
|
try {
|
||||||
|
return taflush();
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public initAutoCreateServer(region: RegionType) {
|
public initAutoCreateServer(region: RegionType) {
|
||||||
return initAutoCreateServer(region);
|
try {
|
||||||
|
return initAutoCreateServer(region);
|
||||||
|
} catch(e) {
|
||||||
|
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user