init
This commit is contained in:
@@ -1,85 +1,86 @@
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { setServerGroup } from '../../../services/serverService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setHiddenData } from '../../../services/memoryCache/hiddenData';
|
||||
import { gameData, reloadResources } from '../../../pubUtils/data';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GMRemote(app);
|
||||
}
|
||||
|
||||
// rpc 定义挪到单独的定义文件(user.rpc.define.ts)。解决ts-node 有可能找不到定义的问题。
|
||||
// 你也可以用其它方法解决,或者没有遇到过这个问题的话,定义还是可以放在这里。
|
||||
|
||||
// UserRpc的命名空间自动合并
|
||||
// declare global {
|
||||
// interface UserRpc {
|
||||
// chat: {
|
||||
// GMRemote: RemoterClass<FrontendSession, GMRemote>;
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
export class GMRemote {
|
||||
|
||||
constructor(private app: Application) {
|
||||
this.app = app;
|
||||
this.channelService = app.get('channelService');
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
|
||||
|
||||
public async setHiddenData(heroes: number[], goods: number[], refTime: number) {
|
||||
try {
|
||||
setHiddenData(heroes, goods, refTime);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setServerGroup() {
|
||||
try {
|
||||
await setServerGroup();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
public async reloadResources(type?: string) {
|
||||
try {
|
||||
reloadResources(type);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setDicParam(field1: string, field2: string, value: string|number) {
|
||||
try {
|
||||
if(dicParam[field1] && dicParam[field1][field2]) dicParam[field1][field2] = value;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setGameDataToApp() {
|
||||
try {
|
||||
this.app.set('gameData', gameData);
|
||||
this.app.set('dicParam', dicParam);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async fun() {
|
||||
try {
|
||||
console.log('预留一个函数,用于之后线上维护时需要使用');
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { setServerGroup } from '../../../services/serverService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setHiddenData } from '../../../services/memoryCache/hiddenData';
|
||||
import { gameData, reloadResources } from '@pubUtils/data';
|
||||
import * as dicParam from '@pubUtils/dicParam';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GMRemote(app);
|
||||
}
|
||||
|
||||
// rpc 定义挪到单独的定义文件(user.rpc.define.ts)。解决ts-node 有可能找不到定义的问题。
|
||||
// 你也可以用其它方法解决,或者没有遇到过这个问题的话,定义还是可以放在这里。
|
||||
|
||||
// UserRpc的命名空间自动合并
|
||||
// declare global {
|
||||
// interface UserRpc {
|
||||
// chat: {
|
||||
// GMRemote: RemoterClass<FrontendSession, GMRemote>;
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
export class GMRemote {
|
||||
|
||||
constructor(private app: Application) {
|
||||
this.app = app;
|
||||
this.channelService = app.get('channelService');
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
|
||||
|
||||
public async setHiddenData(heroes: number[], goods: number[], refTime: number) {
|
||||
try {
|
||||
setHiddenData(heroes, goods, refTime);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setServerGroup() {
|
||||
try {
|
||||
await setServerGroup();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
public async reloadResources(type?: string) {
|
||||
try {
|
||||
reloadResources(type);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setDicParam(field1: string, field2: string, value: string|number) {
|
||||
try {
|
||||
if(dicParam[field1] && dicParam[field1][field2]) dicParam[field1][field2] = value;
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setGameDataToApp() {
|
||||
try {
|
||||
this.app.set('gameData', gameData);
|
||||
this.app.set('dicParam', dicParam);
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async fun() {
|
||||
try {
|
||||
console.log('预留一个函数,用于之后线上维护时需要使用');
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user