import { EventEmitter } from 'events';
import * as Http from 'http';
import { ACUtils } from './cube-utils';

export default class ACServer extends EventEmitter {
    server: Http.Server = Http.createServer();
    private port: number = 8080;

    async run(): Promise<void> {
        this.port = await ACUtils.localPort();
        this.server.listen(this.port);
        this.server.on('request', ()=>{});
        return Promise.resolve();
    }
    connectInfo(): any {
        return {
            ip: ACUtils.localIP(),
            port: this.port
        };
    }
}