Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 信号器升级0.5.3至1.0.x问题_Javascript_Asp.net Mvc_Signalr - Fatal编程技术网

Javascript 信号器升级0.5.3至1.0.x问题

Javascript 信号器升级0.5.3至1.0.x问题,javascript,asp.net-mvc,signalr,Javascript,Asp.net Mvc,Signalr,我最近从signalR 0.5.3升级到1.0.x rc2,我在创建连接时遇到问题 问题是我遇到了一个例外: TypeError:res为空 connection.appRelativeUrl=res.Url 我创建连接的脚本已被剥离到默认演示代码: var connection = $.connection('/signalr'); connection.start(function () { console.log("connecti

我最近从signalR 0.5.3升级到1.0.x rc2,我在创建连接时遇到问题

问题是我遇到了一个例外:

TypeError:res为空

connection.appRelativeUrl=res.Url

我创建连接的脚本已被剥离到默认演示代码:

        var connection = $.connection('/signalr');

        connection.start(function () {
            console.log("connection started!");
        });
但我还是得到了错误。当我进入jquery.signalr.js文件并点击连接代码时:

 var url = connection.url + "/negotiate";
 connection.log("Negotiating with '" + url + "'.");
 $.ajax({
         url: url,
         global: false,
         cache: false,
         type: "GET",
         data: {},
         dataType: connection.ajaxDataType,
         error: function (error) {
              $(connection).triggerHandler(events.onError, [error.responseText]);
              deferred.reject("SignalR: Error during negotiation request: " + error.responseText);
              // Stop the connection if negotiate failed
              connection.stop();
          },
          success: function (res) {
               var keepAliveData = connection.keepAliveData; 
               connection.appRelativeUrl = res.Url;
我正在进入最后一行,res参数为null,这将破坏我的连接尝试。我已经更新了所有信号器依赖项,更改了所有集线器客户端调用,以使用集线器中的其他客户端/服务器属性

正在创建我的/signalr/hubs js脚本,它具有映射到我期望可用的服务器端hub方法的所有正确方法。js文件如下所示:

    /*!
    * ASP.NET SignalR JavaScript Library v1.0.0
    * http://signalr.net/
    *
    * Copyright Microsoft Open Technologies, Inc. All rights reserved.
    * Licensed under the Apache 2.0
    * https://github.com/SignalR/SignalR/blob/master/LICENSE.md
    *
    */

   /// <reference path="..\..\SignalR.Client.JS\Scripts\jquery-1.6.4.js" />
   /// <reference path="jquery.signalR.js" />

      (function ($, window) {
       /// <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/hubs.");
    }

    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.chatHub = this.createHubProxy('chatHub'); 
        proxies.chatHub.client = { };
        proxies.chatHub.server = {
            exitChat: function (chatId) {
            /// <summary>Calls the ExitChat method on the server-side ChatHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"chatId\" type=\"String\">Server side type is System.String</param>
                return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["ExitChat"], $.makeArray(arguments)));
             },

            getChat: function (chatId) {
            /// <summary>Calls the GetChat method on the server-side ChatHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"chatId\" type=\"String\">Server side type is System.String</param>
                return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["GetChat"], $.makeArray(arguments)));
             },

            joinChat: function (chatId, inviteeUserIds, groupId) {
            /// <summary>Calls the JoinChat method on the server-side ChatHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"chatId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"inviteeUserIds\" type=\"Object\">Server side type is System.String[]</param>
            /// <param name=\"groupId\" type=\"String\">Server side type is System.String</param>
                return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["JoinChat"], $.makeArray(arguments)));
             },

            sendChatMessage: function (chatId, messageId, message) {
            /// <summary>Calls the SendChatMessage method on the server-side ChatHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"chatId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"messageId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"message\" type=\"String\">Server side type is System.String</param>
                return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["SendChatMessage"], $.makeArray(arguments)));
             },

            typing: function (chatId, isTyping) {
            /// <summary>Calls the Typing method on the server-side ChatHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"chatId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"isTyping\" type=\"\">Server side type is System.Boolean</param>
                return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["Typing"], $.makeArray(arguments)));
             }
        };

        proxies.debugHub = this.createHubProxy('debugHub'); 
        proxies.debugHub.client = { };
        proxies.debugHub.server = {
            registerWithDebugger: function () {
            /// <summary>Calls the RegisterWithDebugger method on the server-side DebugHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
                return proxies.debugHub.invoke.apply(proxies.debugHub, $.merge(["RegisterWithDebugger"], $.makeArray(arguments)));
             }
        };

        proxies.groupHub = this.createHubProxy('groupHub'); 
        proxies.groupHub.client = { };
        proxies.groupHub.server = {
            joinGroup: function (userId, groupId) {
            /// <summary>Calls the JoinGroup method on the server-side GroupHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"userId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"groupId\" type=\"String\">Server side type is System.String</param>
                return proxies.groupHub.invoke.apply(proxies.groupHub, $.merge(["JoinGroup"], $.makeArray(arguments)));
             },

            joinGroups: function (userId) {
            /// <summary>Calls the JoinGroups method on the server-side GroupHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"userId\" type=\"String\">Server side type is System.String</param>
                return proxies.groupHub.invoke.apply(proxies.groupHub, $.merge(["JoinGroups"], $.makeArray(arguments)));
             },

            leaveGroup: function (userId, groupId) {
            /// <summary>Calls the LeaveGroup method on the server-side GroupHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"userId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"groupId\" type=\"String\">Server side type is System.String</param>
                return proxies.groupHub.invoke.apply(proxies.groupHub, $.merge(["LeaveGroup"], $.makeArray(arguments)));
             }
        };

        proxies.userHub = this.createHubProxy('userHub'); 
        proxies.userHub.client = { };
        proxies.userHub.server = {
            registerUserClient: function (userId) {
            /// <summary>Calls the RegisterUserClient method on the server-side UserHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"userId\" type=\"String\">Server side type is System.String</param>
                return proxies.userHub.invoke.apply(proxies.userHub, $.merge(["RegisterUserClient"], $.makeArray(arguments)));
             },

            updateUserClientStatus: function (userId, latestHeartbeat, latestInteractivity) {
            /// <summary>Calls the UpdateUserClientStatus method on the server-side UserHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
            /// <param name=\"userId\" type=\"String\">Server side type is System.String</param>
            /// <param name=\"latestHeartbeat\" type=\"Object\">Server side type is System.DateTime</param>
            /// <param name=\"latestInteractivity\" type=\"Object\">Server side type is System.DateTime</param>
                return proxies.userHub.invoke.apply(proxies.userHub, $.merge(["UpdateUserClientStatus"], $.makeArray(arguments)));
             }
        };

        return proxies;
    };

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

   }(window.jQuery, window));
/*!
*ASP.NET信号器JavaScript库v1.0.0
* http://signalr.net/
*
*版权所有Microsoft Open Technologies,Inc.保留所有权利。
*根据Apache2.0许可
* https://github.com/SignalR/SignalR/blob/master/LICENSE.md
*
*/
/// 
/// 
(函数($,窗口){
/// 
“严格使用”;
if(类型($.signalR)!=“功能”){
抛出新错误(“SignalR:SignalR未加载。请确保在~/SignalR/hubs之前引用jquery.SignalR-x.js”);
}
var signalR=$.signalR;
函数makeProxyCallback(集线器,回调){
返回函数(){
//调用客户机中心方法
apply(hub,$.makeArray(参数));
};
}
函数注册表代理(实例,shouldSubscribe){
var键、hub、memberKey、memberValue、subscriptionMethod;
例如(输入实例){
if(instance.hasOwnProperty(key)){
hub=实例[键];
如果(!(hub.hubName)){
//不是客户端中心
继续;
}
如果(应该订阅){
//我们想订阅中心活动
subscriptionMethod=hub.on;
}
否则{
//我们想取消中心活动的订阅
subscriptionMethod=hub.off;
}
//循环浏览中心上的所有成员,并查找要订阅/取消订阅的客户端中心函数
for(hub.client中的memberKey){
if(hub.client.hasOwnProperty(memberKey)){
memberValue=hub.client[memberKey];
if(!$.isFunction(memberValue)){
//不是客户端中心功能
继续;
}
调用(hub,memberKey,makeProxyCallback(hub,memberValue));
}
}
}
}
}
$.hubConnection.prototype.createHubProxies=函数(){
变量代理={};
这个。正在启动(函数(){
//将集线器代理注册为已订阅
//(例如,shouldSubscribe)
注册表代理(代理,真实);
这是。_registerSubscribedHubs();
}).断开连接(功能(){
//当我们“断开连接”时,取消订阅所有集线器代理。这是为了确保我们不会重新添加功能性回调。
//(例如,shouldSubscribe)
注册代理(代理,虚假);
});
proxies.chatHub=this.createHubProxy('chatHub');
proxies.chatHub.client={};
proxies.chatHub.server={
exitChat:函数(chatId){
///调用服务器端ChatHub上的ExitChat方法。
;返回jQuery.Deferred()承诺。
///服务器端类型为System.String
返回proxies.chatHub.invoke.apply(proxies.chatHub,$.merge([“ExitChat”],$.makeArray(参数));
},
getChat:函数(chatId){
///调用服务器端ChatHub上的GetChat方法。
;返回jQuery.Deferred()承诺。
///服务器端类型为System.String
返回proxies.chatHub.invoke.apply(proxies.chatHub,$.merge([“GetChat”],$.makeArray(参数));
},
joinChat:函数(chatId、inviteUserID、groupId){
///调用服务器端ChatHub上的JoinChat方法。
;返回jQuery.Deferred()承诺。
///服务器端类型为System.String
///服务器端类型为System.String[]
///服务器端类型为System.String
返回proxies.chatHub.invoke.apply(proxies.chatHub,$.merge([“JoinChat”],$.makeArray(参数));
},
sendChatMessage:函数(chatId、messageId、message){
///调用服务器端ChatHub上的SendChatMessage方法。
;返回jQuery.Deferred()承诺。
///服务器端类型为System.String
///服务器端类型为System.String
///服务器端类型为System.String
返回proxies.chatHub.invoke.apply(proxies.chatHub,$.merge([“SendChatMessage”],$.makeArray(参数));
},
键入:函数(chatId、isTyping){
///调用服务器端ChatHub上的键入方法。
;返回jQuery.Deferred()承诺。
///服务器端类型为System.String
///服务器端类型为System.Boolean
返回proxies.chatHub.invoke.apply(proxies.chatHub,$.merge([“键入”],$.makeArray(参数));
}
};
proxies.debugHub=this.createhubbroxy('debugHub');
proxies.debugHub.client={};
proxies.debugHub.server={
registerWithDebugger:函数(){
///调用服务器端Deb上的RegisterWithDebugger方法