Add bridge application name to options storage

This commit is contained in:
hensm
2019-05-17 15:03:27 +01:00
parent 964f54a06b
commit c16566cfad
4 changed files with 26 additions and 11 deletions

View File

@@ -535,8 +535,10 @@ const statusBridgeReceivers = new Map<string, Receiver>();
/**
* Create status bridge, set event handlers and initialize.
*/
function initStatusBridge () {
statusBridge = nativeMessaging.connectNative(APPLICATION_NAME);
async function initStatusBridge () {
const applicationName = await options.get("bridgeApplicationName");
statusBridge = nativeMessaging.connectNative(applicationName);
statusBridge.onDisconnect.addListener(onStatusBridgeDisconnect);
statusBridge.onMessage.addListener(onStatusBridgeMessage);
@@ -705,11 +707,14 @@ async function onConnectShim (port: browser.runtime.Port) {
shimMap.delete(shimId);
}
const applicationName = await options.get("bridgeApplicationName");
// Spawn bridge app instance
const bridgePort = nativeMessaging.connectNative(APPLICATION_NAME);
const bridgePort = nativeMessaging.connectNative(applicationName);
if (bridgePort.error) {
console.error(`Failed connect to ${APPLICATION_NAME}:`
console.error(`Failed connect to ${applicationName}:`
, bridgePort.error.message);
}
@@ -722,10 +727,10 @@ async function onConnectShim (port: browser.runtime.Port) {
bridgePort.onDisconnect.addListener(() => {
if (bridgePort.error) {
console.error(`${APPLICATION_NAME} disconnected:`
console.error(`${applicationName} disconnected:`
, bridgePort.error.message);
} else {
console.info(`${APPLICATION_NAME} disconnected`);
console.info(`${applicationName} disconnected`);
}
});