"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const http_1 = __importDefault(require("http"));
const fillReqUrl_1 = __importDefault(require("./fillReqUrl"));
class HttpServer {
    constructor() {
        this.server = http_1.default.createServer();
    }
    setHttpHandler(httpHandler) {
        this.server.on('request', httpHandler.handle.bind(httpHandler));
    }
    setConnectHandler(connectHandler) {
        this.server.on('connect', connectHandler.handle.bind(connectHandler));
    }
    setUpgradeHandler(upgradeHandler) {
        this.server.on('upgrade', (req, socket, head) => {
            fillReqUrl_1.default(req, 'ws');
            upgradeHandler.handle(req, socket, head);
        });
    }
    setErrorHandler(errorHandler) {
        this.server.on('error', errorHandler.handle.bind(errorHandler));
    }
    listen(port) {
        this.server.listen(port, '0.0.0.0');
    }
}
exports.HttpServer = HttpServer;
//# sourceMappingURL=http.js.map