1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.AbstractWsAdapter = void 0;
|
4 | const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
|
5 | const core_1 = require("@nestjs/core");
|
6 | const constants_1 = require("../constants");
|
7 | class AbstractWsAdapter {
|
8 | constructor(appOrHttpServer) {
|
9 | if (appOrHttpServer && appOrHttpServer instanceof core_1.NestApplication) {
|
10 | this.httpServer = appOrHttpServer.getUnderlyingHttpServer();
|
11 | }
|
12 | else {
|
13 | this.httpServer = appOrHttpServer;
|
14 | }
|
15 | }
|
16 | bindClientConnect(server, callback) {
|
17 | server.on(constants_1.CONNECTION_EVENT, callback);
|
18 | }
|
19 | bindClientDisconnect(client, callback) {
|
20 | client.on(constants_1.DISCONNECT_EVENT, callback);
|
21 | }
|
22 | async close(server) {
|
23 | const isCallable = server && (0, shared_utils_1.isFunction)(server.close);
|
24 | isCallable && (await new Promise(resolve => server.close(resolve)));
|
25 | }
|
26 |
|
27 | async dispose() { }
|
28 | }
|
29 | exports.AbstractWsAdapter = AbstractWsAdapter;
|