diff --git a/Gruntfile.js b/Gruntfile.js index 63f545868..f535e59a2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -34,7 +34,7 @@ const srcFiles = ['src/**/*.js', 'index.js', 'Gruntfile.js']; //optional dependencies that we ship. const optionalDependencies = [ - 'js-adapter/**', + 'node-adapter/**', 'runtime-p2p/**' ]; diff --git a/index.js b/index.js index 1b7dd2051..0cd1e8dad 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,8 @@ import { import { default as connectionManager, - meshEnabled + meshEnabled, + isMeshEnabled } from './src/browser/connection_manager'; import * as log from './src/browser/log'; @@ -138,7 +139,7 @@ portDiscovery.on('runtime/launched', (portInfo) => { log.writeToLog('info', `Port discovery message received ${JSON.stringify(portInfo)}`); //TODO: Include REALM in the determination. - if (meshEnabled && portInfo.port !== myPortInfo.port) { + if (meshEnabled && portInfo.port !== myPortInfo.port && isMeshEnabled(portInfo.options)) { connectionManager.connectToRuntime(`${myPortInfo.version}:${myPortInfo.port}`, portInfo).then((runtimePeer) => { //one connected we broadcast our port discovery message. diff --git a/src/browser/connection_manager.ts b/src/browser/connection_manager.ts index 92722b7fa..c40f6a3f2 100644 --- a/src/browser/connection_manager.ts +++ b/src/browser/connection_manager.ts @@ -13,6 +13,7 @@ Please contact OpenFin Inc. at sales@openfin.co to obtain a Commercial License. declare let process: any; import { EventEmitter } from 'events'; import { Identity } from './api_protocol/transport_strategy/api_transport_base'; +import { ArgMap, PortInfo } from './port_discovery'; // npm modules // (none) @@ -21,16 +22,13 @@ import { Identity } from './api_protocol/transport_strategy/api_transport_base'; const coreState = require('./core_state'); import * as log from './log'; - //TODO: pre-release flag, this will go away once we release multi runtime. const multiRuntimeCommandLineFlag = 'enable-multi-runtime'; const enableMeshCommandLineFlag = 'enable-mesh'; const securityRealmFlag = 'security-realm'; +//TODO: pre-release flag, this will go away once we release multi runtime const multiRuntimeEnabled = coreState.argo[multiRuntimeCommandLineFlag]; -const enableMesh = coreState.argo[enableMeshCommandLineFlag]; -const securityRealm = coreState.argo[securityRealmFlag]; - let connectionManager: any; let meshEnabled = false; @@ -46,14 +44,6 @@ function startConnectionManager() { } } -//TODO: pre-release flag, this will go away once we release multi runtime -if (multiRuntimeEnabled) { - - if (!securityRealm || enableMesh) { - startConnectionManager(); - } -} - function buildNoopConnectionManager() { connectionManager = new EventEmitter(); connectionManager.connectToRuntime = () => { @@ -71,6 +61,21 @@ function buildNoopConnectionManager() { connectionManager.connections = []; } +function isMeshEnabled(args: ArgMap) { + let enabled = false; + const enableMesh = args[enableMeshCommandLineFlag]; + const securityRealm = args[securityRealmFlag]; + + if (!securityRealm || enableMesh) { + enabled = true; + } + + return enabled; +} + +if (multiRuntimeEnabled && isMeshEnabled(coreState.argo)) { + startConnectionManager(); +} /* Note that these should match the definitions found here: @@ -90,15 +95,6 @@ interface IdentityAddress { identity: Identity; } -interface PortInfo { - version: any; - sslPort: number; - port: number; - requestedVersion?: string; - securityRealm?: string; - runtimeInformationChannel?: string; -} - interface ConnectionManager extends EventEmitter { connections: Array; connectToRuntime: (uuid: string, portInfo: PortInfo) => Promise; @@ -107,4 +103,4 @@ interface ConnectionManager extends EventEmitter { export default connectionManager as ConnectionManager; -export { meshEnabled, PeerRuntime }; +export { meshEnabled, PeerRuntime, isMeshEnabled }; diff --git a/src/browser/port_discovery.ts b/src/browser/port_discovery.ts index a4b14c871..3aabe5973 100644 --- a/src/browser/port_discovery.ts +++ b/src/browser/port_discovery.ts @@ -21,6 +21,7 @@ export interface PortInfo { version: any; sslPort: number; port: number; + options: ArgMap; requestedVersion?: string; securityRealm?: string; runtimeInformationChannel: string; @@ -61,10 +62,11 @@ export class PortDiscovery extends EventEmitter { version: ver.openfin, // tslint:enable sslPort: -1, - port: port, + port, + options: args, requestedVersion: versionKeyword, - securityRealm: securityRealm, - runtimeInformationChannel: runtimeInformationChannel + securityRealm, + runtimeInformationChannel }; return portDiscoveryPayload;