rpc优化:所有remote加上try catch
This commit is contained in:
@@ -14,6 +14,7 @@ import { RankFirstType } from '../../../db/RankFirst';
|
||||
import { LotType } from '../../../db/Lot';
|
||||
import { _checkFilterWords, getTire, taflush } from '../../../services/sdkService';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -55,14 +56,18 @@ export class ChatRemote {
|
||||
*
|
||||
*/
|
||||
public async addWorldChannel(roleId: string, serverId: number, sid: string, flag: boolean = true) {
|
||||
const name = `world${serverId}`;
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!channel) return;
|
||||
channel.add(roleId, sid);
|
||||
let param = {
|
||||
roleId
|
||||
};
|
||||
return this.getWorldChannel(name);
|
||||
try {
|
||||
const name = `world${serverId}`;
|
||||
let channel = this.channelService.getChannel(name, flag);
|
||||
if (!channel) return;
|
||||
channel.add(roleId, sid);
|
||||
let param = {
|
||||
roleId
|
||||
};
|
||||
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) {
|
||||
const name = `world${serverId}`;
|
||||
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!channel) return;
|
||||
channel.leave(roleId, sid);
|
||||
try {
|
||||
const name = `world${serverId}`;
|
||||
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
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 信息
|
||||
*/
|
||||
public async sendWorldMessage(serverId: number, param: any) {
|
||||
const name = `world${serverId}`;
|
||||
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!!channel) {
|
||||
channel.pushMessage('onWorldMessage', resResult(STATUS.SUCCESS, param));
|
||||
try {
|
||||
const name = `world${serverId}`;
|
||||
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
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
|
||||
*/
|
||||
public async addChannel(channelName: string, roleId: string, sid: string) {
|
||||
let channel = this.channelService.getChannel(channelName, true);
|
||||
if (!channel) return;
|
||||
addUserToChannel(channel, new ChannelUser(roleId, sid));
|
||||
try {
|
||||
let channel = this.channelService.getChannel(channelName, true);
|
||||
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
|
||||
*/
|
||||
public async leaveChannel(channelName: string, roleId: string, sid: string) {
|
||||
let channel = this.channelService.getChannel(channelName, false);
|
||||
// leave channel
|
||||
if (!channel) return;
|
||||
channel.leave(roleId, sid);
|
||||
try {
|
||||
let channel = this.channelService.getChannel(channelName, false);
|
||||
// leave channel
|
||||
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
|
||||
*/
|
||||
public async sendGroupMsg(roomId: string, msg: Partial<GroupMessageType>) {
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
const roleInfo = await getSimpleRoleInfo(msg.roleId);
|
||||
channel.pushMessage(ON_GROUP_MSG_ROUTE, resResult(STATUS.SUCCESS, { ...msg, roleInfo }));
|
||||
try {
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public async sendGuildActivityEnd(serverId: number) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, {}));
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
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
|
||||
*/
|
||||
public async sendRaceActivityStart(serverId: number) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.RACE_ACTIVITY_START, resResult(STATUS.SUCCESS, {}));
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
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
|
||||
*/
|
||||
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资源
|
||||
*/
|
||||
public async reloadResources() {
|
||||
reloadResources();
|
||||
try {
|
||||
reloadResources();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,11 +259,15 @@ export class ChatRemote {
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendGuildActivityUpdate(serverId: number) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
let guildActivities = getAllGuildActivityStatus();
|
||||
channel.pushMessage(this.GUILD_ACTIVITY_STATUS_UPDATE, resResult(STATUS.SUCCESS, { guildActivities }));
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
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 邮件内容
|
||||
*/
|
||||
public async sendMail(serverId: number, path: string, data: { mails: MailParam[] }) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(path, resResult(STATUS.SUCCESS, data));
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, 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 };
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, 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 };
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,49 +322,81 @@ export class ChatRemote {
|
||||
* @param guildCode
|
||||
*/
|
||||
public async sendGuildAuction(guildCode: string, lot: LotType) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||
return true;
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.GUILD, guildCode);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
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) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionOver', resResult(STATUS.SUCCESS, { lot }));
|
||||
return true;
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
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[] }) {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionUpdate', resResult(STATUS.SUCCESS, params));
|
||||
return true;
|
||||
try {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if(!channel) return false;
|
||||
|
||||
channel.pushMessage('onAuctionUpdate', resResult(STATUS.SUCCESS, params));
|
||||
return true;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
setServerMainten(serverIds, startTime, endTime);
|
||||
try {
|
||||
setServerMainten(serverIds, startTime, endTime);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public stopServerMainten(serverIds: number[]) {
|
||||
stopServerMainten(serverIds);
|
||||
try {
|
||||
stopServerMainten(serverIds);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public getServerMainten(serverId: number) {
|
||||
return getServerMainten(serverId);
|
||||
try {
|
||||
return getServerMainten(serverId);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
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 { DividendType } from '../../../db/Dividend';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -130,14 +131,18 @@ export class GuildRemote {
|
||||
* @param sid 玩家sid
|
||||
*/
|
||||
public memberQuit(guildCode: string, roleId: string, guild: GuildType, sid?: string) {
|
||||
// 被踢出公会
|
||||
this.pushMessageByUids(guildCode, this.MEMBER_QUIT, roleId, {
|
||||
code: guildCode,
|
||||
roleId
|
||||
}, sid);
|
||||
// 更新人数减少
|
||||
this.updateInfo(guildCode, { memberCnt: guild.memberCnt, guildCe: guild.guildCe });
|
||||
leaveGuildChannel(roleId, sid, guildCode);
|
||||
try {
|
||||
// 被踢出公会
|
||||
this.pushMessageByUids(guildCode, this.MEMBER_QUIT, roleId, {
|
||||
code: guildCode,
|
||||
roleId
|
||||
}, sid);
|
||||
// 更新人数减少
|
||||
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
|
||||
*/
|
||||
public dismiss(guildCode: string) {
|
||||
let channel = this.pushMessage(guildCode, this.DISMISS, { code: guildCode });
|
||||
if (!!channel) {
|
||||
channel.destroy();
|
||||
try {
|
||||
let channel = this.pushMessage(guildCode, this.DISMISS, { code: guildCode });
|
||||
if (!!channel) {
|
||||
channel.destroy();
|
||||
}
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +166,11 @@ export class GuildRemote {
|
||||
* @param info 军团相关信息
|
||||
*/
|
||||
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.promotion(guildCode, roleId);
|
||||
}catch(e) {
|
||||
console.log(e.stack)
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +197,13 @@ export class GuildRemote {
|
||||
* @param roleId 旧团长id
|
||||
*/
|
||||
public demotion(guildCode: string, roleId: string) {
|
||||
this.pushMessageByUids(guildCode, this.DEMOTION, roleId, {
|
||||
code: guildCode
|
||||
});
|
||||
try {
|
||||
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
|
||||
*/
|
||||
public promotion(guildCode: string, roleId: string) {
|
||||
this.pushMessageByUids(guildCode, this.PROMOTION, roleId, {
|
||||
code: guildCode
|
||||
});
|
||||
try {
|
||||
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 动态
|
||||
*/
|
||||
public addRec(guildRecType: GuildRecType) {
|
||||
let { guildCode, type, params, createTime } = guildRecType;
|
||||
this.pushMessage(guildCode, this.GUILD_REC_ADD, { type, params, createTime });
|
||||
try {
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public async sendGuildActivityEnd(guildCode: string) {
|
||||
console.log("MSG END")
|
||||
this.pushMessage(guildCode, this.GUILD_ACTIVITY_END, {});
|
||||
try {
|
||||
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 宣战数量
|
||||
*/
|
||||
public async sendGuildCityDeclare(cityId: number, declareGuildCode: string, declareCount: number) {
|
||||
this.pushMessageToCity(cityId, this.GUILD_CITY_DECLARE, {
|
||||
cityId,
|
||||
declareGuildCode,
|
||||
declareCount
|
||||
});
|
||||
this.pushMessage(declareGuildCode, this.GUILD_CITY_DECLARE, {
|
||||
cityId,
|
||||
declareGuildCode,
|
||||
declareCount
|
||||
});
|
||||
try {
|
||||
this.pushMessageToCity(cityId, this.GUILD_CITY_DECLARE, {
|
||||
cityId,
|
||||
declareGuildCode,
|
||||
declareCount
|
||||
});
|
||||
this.pushMessage(declareGuildCode, this.GUILD_CITY_DECLARE, {
|
||||
cityId,
|
||||
declareGuildCode,
|
||||
declareCount
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,10 +312,14 @@ export class GuildRemote {
|
||||
* @param gateHp 血条
|
||||
*/
|
||||
public async pushCityGateHp(cityId: number, gateHp: number) {
|
||||
this.pushMessageToCity(cityId, this.GUILD_CITY_ACT_HP, {
|
||||
cityId,
|
||||
gateHp
|
||||
});
|
||||
try {
|
||||
this.pushMessageToCity(cityId, this.GUILD_CITY_ACT_HP, {
|
||||
cityId,
|
||||
gateHp
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,12 +329,16 @@ export class GuildRemote {
|
||||
* @param ranks 军团排名和自己所在的排名
|
||||
*/
|
||||
public async pushRaceHorseUpdate(guildCode: string, woodenHorseList: WoodenHorse[], ranks: GuildRankParams, events: Event[]) {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_UPDATE, {
|
||||
timestamp: Date.now(),
|
||||
woodenHorseList,
|
||||
...ranks,
|
||||
events
|
||||
});
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_UPDATE, {
|
||||
timestamp: Date.now(),
|
||||
woodenHorseList,
|
||||
...ranks,
|
||||
events
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -295,10 +348,14 @@ export class GuildRemote {
|
||||
* @param woodenHorse 木马
|
||||
*/
|
||||
public async pushRaceHorseJoin(guildCode: string, woodenHorse: WoodenHorse) {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_JOIN, {
|
||||
timestamp: Date.now(),
|
||||
woodenHorse
|
||||
});
|
||||
try {
|
||||
this.pushMessage(guildCode, this.GUILD_RACE_JOIN, {
|
||||
timestamp: Date.now(),
|
||||
woodenHorse
|
||||
});
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +363,11 @@ export class GuildRemote {
|
||||
* @param guildCode
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public async sendPopUpActivity(guildCode: string, data: any[]) {
|
||||
console.log("sendPopUpActivity")
|
||||
this.pushMessage(guildCode, this.GUILD_POP_UP_ACTIVITY, data);
|
||||
try {
|
||||
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 军团内容
|
||||
*/
|
||||
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) {
|
||||
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;}) {
|
||||
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[] }) {
|
||||
if(param.lots) this.pushMessage(guildCode, this.AUCTION_UPDATE, { lots: param.lots });
|
||||
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_UPDATE, { dividends: param.dividends });
|
||||
try {
|
||||
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[] }) {
|
||||
if(param.lots) this.pushMessage(guildCode, this.AUCTION_ADD, { lots: param.lots });
|
||||
if(param.dividends) this.pushMessage(guildCode, this.DIVIDEND_ADD, { dividends: param.dividends });
|
||||
try {
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user