Google chrome extension 信号机集线器未加载到扩展边缘
为了澄清,此问题与基于预铬的Edge版本有关。 我正在尝试将Chrome扩展转换为边缘扩展,并使用Microsoft边缘扩展工具包进行转换。该扩展连接到运行在简单Windows窗体应用程序中的本地信号器集线器,以便将消息从web应用程序来回传递到外部连接的设备。尝试连接时,我从信号器收到此错误: 错误:信号器:加载集线器时出错。确保集线器引用正确,例如script src='/signal/js'>/script> 我发现它位于signalrjquery文件中,上面有一条注释说,当正确引用集线器时,错误消息将被替换。我可以导航到localhost:9562/signal/hubs,并从hub中看到以下代码Google chrome extension 信号机集线器未加载到扩展边缘,google-chrome-extension,signalr,microsoft-edge,microsoft-edge-extension,Google Chrome Extension,Signalr,Microsoft Edge,Microsoft Edge Extension,为了澄清,此问题与基于预铬的Edge版本有关。 我正在尝试将Chrome扩展转换为边缘扩展,并使用Microsoft边缘扩展工具包进行转换。该扩展连接到运行在简单Windows窗体应用程序中的本地信号器集线器,以便将消息从web应用程序来回传递到外部连接的设备。尝试连接时,我从信号器收到此错误: 错误:信号器:加载集线器时出错。确保集线器引用正确,例如script src='/signal/js'>/script> 我发现它位于signalrjquery文件中,上面有一条注释说,当正确引用集线器
/*!
* ASP.NET SignalR JavaScript Library v2.2.2
* http://signalr.net/
*
* Copyright (c) .NET Foundation. All rights reserved.
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
*
*/
/// <reference path="..\..\SignalR.Client.JS\Scripts\jquery-1.6.4.js" />
/// <reference path="jquery.signalR.js" />
(function ($, window, undefined) {
/// <param name="$" type="jQuery" />
"use strict";
if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
}
var signalR = $.signalR;
function makeProxyCallback(hub, callback) {
return function () {
// Call the client hub method
callback.apply(hub, $.makeArray(arguments));
};
}
function registerHubProxies(instance, shouldSubscribe) {
var key, hub, memberKey, memberValue, subscriptionMethod;
for (key in instance) {
if (instance.hasOwnProperty(key)) {
hub = instance[key];
if (!(hub.hubName)) {
// Not a client hub
continue;
}
if (shouldSubscribe) {
// We want to subscribe to the hub events
subscriptionMethod = hub.on;
} else {
// We want to unsubscribe from the hub events
subscriptionMethod = hub.off;
}
// Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
for (memberKey in hub.client) {
if (hub.client.hasOwnProperty(memberKey)) {
memberValue = hub.client[memberKey];
if (!$.isFunction(memberValue)) {
// Not a client hub function
continue;
}
subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
}
}
}
}
}
$.hubConnection.prototype.createHubProxies = function () {
var proxies = {};
this.starting(function () {
// Register the hub proxies as subscribed
// (instance, shouldSubscribe)
registerHubProxies(proxies, true);
this._registerSubscribedHubs();
}).disconnected(function () {
// Unsubscribe all hub proxies when we "disconnect". This is to ensure that we do not re-add functional call backs.
// (instance, shouldSubscribe)
registerHubProxies(proxies, false);
});
proxies['signalRHub'] = this.createHubProxy('signalRHub');
proxies['signalRHub'].client = { };
proxies['signalRHub'].server = {
register: function () {
return proxies['signalRHub'].invoke.apply(proxies['signalRHub'], $.merge(["Register"], $.makeArray(arguments)));
},
setHiCalMode: function (mode) {
return proxies['signalRHub'].invoke.apply(proxies['signalRHub'], $.merge(["SetHiCalMode"], $.makeArray(arguments)));
}
};
return proxies;
};
signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });
$.extend(signalR, signalR.hub.createHubProxies());
}(window.jQuery, window));
我猜您尝试移植的扩展正在使用NativeMessaging。如果是,根据Edge的扩展策略,扩展将无法直接与Win32应用程序通信。您需要将Win32应用程序转换为桌面应用程序,同时使用一个无头UWP应用程序作为中间件,以与Extension和Win32应用程序通信消息 您可以在此处进一步了解这一点:
$.connection.hub.url = 'http://localhost:9562/signalr';
$.connection.hub.start().done(init);
signalrHubProxy = $.connection.signalRHub;