import { Application, ChannelService, HandlerService, } from 'pinus';
import { setHiddenData } from '../../../services/dataService';
import { setGVGServerGroup } from '../../../services/gvg/gvgService';
import { errlogger } from '../../../util/logger';

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 setGVGServerGroup() {
        try {
            await setGVGServerGroup();
        } catch(e) {
            errlogger.error(`remote ${__filename} \n ${e.stack}`);
        } 
    }
    
}