"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
class _HTTPServer extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({ fi: ['opt'], fo: [], i: ['port', 'res', 'done'], o: ['req'] }, {}, system, _ids_1.ID_HTTP_SERVER);
        this._buffer = [];
    }
    f({ opt }, done) {
        const { timeout } = opt;
        const { api: { http: { server: { local: HTTPServer }, }, }, } = this.__system;
        if (!HTTPServer) {
            done(undefined, 'HTTP Server API not supported');
        }
        const server = HTTPServer(opt);
        this._server = server;
    }
    onIterDataInputData(name, data) {
        if (name === 'port') {
            if (this._server) {
                const port = data;
                this._server.listen(port, (req, done) => {
                    this._buffer.unshift([req, done]);
                });
            }
        }
    }
}
exports.default = _HTTPServer;
//# sourceMappingURL=index.js.map