import { Application, ChannelService, HandlerService, } from 'pinus';
import { reloadResources } from '../../../pubUtils/data';
import { settleOrderFromRedisPub } from '../../../services/orderService';
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
import { taflush } from '../../../services/sdkService';

export default function (app: Application) {
    new HandlerService(app, {});
    return new OrderRemote(app);
}

export class OrderRemote {

    constructor(private app: Application) {
        this.app = app;
        this.channelService = app.get('channelService');
    }

    private channelService: ChannelService;

    /**
     * 重载json资源
     */
    public async reloadResources() {
        reloadResources();
    }

    public async settleOrderFromRedisPub(message: string) {
        await settleOrderFromRedisPub(message);
    }

    public setServerMainten(serverIds: number[], startTime: number, endTime: number) {
        setServerMainten(serverIds, startTime, endTime);
    }

    public stopServerMainten(serverIds: number[]) {
        stopServerMainten(serverIds);
    }

    public getServerMainten(serverId: number) {
        return getServerMainten(serverId);
    }
        
    public taflush() {
        return taflush();
    }
}