信号器服务器不会使用正确的集线器名创建信号器集线器代理

时间:2015-11-24 07:04:59

标签: jquery asp.net signalr signalr-hub signalr.client

我创建了2个信号器Hub类,它继承自Microsoft.AspNet.SignalR.Hub,ActivityFeedHub类和ChannelHub类。我收到ChannelHub类的警告,类名不是CLS投诉,因为基类Hub不是CLS投诉。 生成的/ signalr / hubs文件错误。应该创建两个集线器代理,即“activityFeedHub'和' channelHub' ,而是' channelHub'它会创建一些名称和方法名称错误的pr0xy,即' K' 。以下是文件。每当我尝试使用" $。connection.channelHub"使用channelHub代理名称访问连接时。它给了我错误 - 未捕获的TypeError:无法读取属性'客户端'未定义的

  

有人可以告诉我这里的问题,并建议我   修复

    $.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['activityFeedHub'] = this.createHubProxy('activityFeedHub'); 
        proxies['activityFeedHub'].client = { };
        proxies['activityFeedHub'].server = {
            joinActivityFeed: function (ActivityFeedActorID) {
                return proxies['activityFeedHub'].invoke.apply(proxies['activityFeedHub'], $.merge(["JoinActivityFeed"], $.makeArray(arguments)));
             },

            leaveActivityFeed: function (ActivityFeedActorID) {
                return proxies['activityFeedHub'].invoke.apply(proxies['activityFeedHub'], $.merge(["LeaveActivityFeed"], $.makeArray(arguments)));
             },

            updateActivity: function (relevantActivity) {
                return proxies['activityFeedHub'].invoke.apply(proxies['activityFeedHub'], $.merge(["UpdateActivity"], $.makeArray(arguments)));
             }
        };

        proxies['k'] = this.createHubProxy('k'); 
        proxies['k'].client = { };
        proxies['k'].server = {
            a: function (channelID) {
                return proxies['k'].invoke.apply(proxies['k'], $.merge(["a"], $.makeArray(arguments)));
             },

            b: function (pinnedItem) {
                return proxies['k'].invoke.apply(proxies['k'], $.merge(["b"], $.makeArray(arguments)));
             },

            c: function (ChannelID) {
                return proxies['k'].invoke.apply(proxies['k'], $.merge(["c"], $.makeArray(arguments)));
             },

            d: function (channelId) {
                return proxies['k'].invoke.apply(proxies['k'], $.merge(["d"], $.makeArray(arguments)));
             },

            e: function (channelId) {
                return proxies['k'].invoke.apply(proxies['k'], $.merge(["e"], $.makeArray(arguments)));
             }
        };

        return proxies;
    };

    signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });
    $.extend(signalR, signalR.hub.createHubProxies());

}(window.jQuery, window));

1 个答案:

答案 0 :(得分:0)

它是一个混淆问题。它通过去混淆Hub类来修复,其中信号器服务器无法使用正确的hubname创建正确的proxiy。 这与Hub类是非CLS投诉无关。