2015-11-24 42 views
1

我創建了2個signalr Hub類,它繼承自Microsoft.AspNet.SignalR.Hub,ActivityFeedHub類和ChannelHub類。由於基類Hub不是CLS投訴,因此我得到ChannelHub類的警告,即類名不是CLS投訴。 生成的/ signalr/hubs文件錯誤。應創建兩個集線器代理,即'activityFeedHub'和'channelHub',而'channelHub'則創建一些名稱錯誤且方法名稱爲'K'的pr0xy。以下是該文件。每當我嘗試使用channelHub代理名稱使用「$ .connection.channelHub」訪問連接,它會給我錯誤 - 未捕獲TypeError:無法讀取未定義的屬性「客戶端」。Signalr服務器不會創建具有正確集線器名稱的信號集線器代理服務器

Can someone please let me know what is the issue here and suggest me a fix

$.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)); 

回答

0

它是一種混淆的問題。它通過去混淆Hub類而得到修復,因爲該類的信號服務器無法使用正確的hubname創建正確的proxiy。 這與Hub類非CLS投訴無關。