"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const core_1 = require("@nestjs/core");
const constants_1 = require("../constants");
class AbstractWsAdapter {
constructor(appOrHttpServer) {
if (appOrHttpServer && appOrHttpServer instanceof core_1.NestApplication) {
this.httpServer = appOrHttpServer.getUnderlyingHttpServer();
}
else {
this.httpServer = appOrHttpServer;
}
}
bindClientConnect(server, callback) {
server.on(constants_1.CONNECTION_EVENT, callback);
}
bindClientDisconnect(client, callback) {
client.on(constants_1.DISCONNECT_EVENT, callback);
}
close(server) {
const isCallable = server && shared_utils_1.isFunction(server.close);
isCallable && server.close();
}
}
exports.AbstractWsAdapter = AbstractWsAdapter;