UNPKG

@microsoft/dev-tunnels-connections

Version:

Tunnels library for Visual Studio tools

44 lines 1.47 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. Object.defineProperty(exports, "__esModule", { value: true }); exports.MultiModeTunnelHost = void 0; const dev_tunnels_contracts_1 = require("@microsoft/dev-tunnels-contracts"); const uuid_1 = require("uuid"); const tunnelConnectionBase_1 = require("./tunnelConnectionBase"); /** * Aggregation of multiple tunnel hosts. */ class MultiModeTunnelHost extends tunnelConnectionBase_1.TunnelConnectionBase { constructor() { super(dev_tunnels_contracts_1.TunnelAccessScopes.Host); this.hosts = []; } /** * @deprecated Use `connect()` instead. */ async start(tunnel) { await this.connect(tunnel); } async connect(tunnel, options, cancellation) { const startTasks = []; this.hosts.forEach((host) => { startTasks.push(host.connect(tunnel, options, cancellation)); }); await Promise.all(startTasks); } async refreshPorts() { const refreshTasks = []; this.hosts.forEach((host) => { refreshTasks.push(host.refreshPorts()); }); await Promise.all(refreshTasks); } async dispose() { await Promise.all(this.hosts.map((host) => host.dispose())); await super.dispose(); } } exports.MultiModeTunnelHost = MultiModeTunnelHost; MultiModeTunnelHost.hostId = (0, uuid_1.v4)(); //# sourceMappingURL=multiModeTunnelHost.js.map