Unable to get property 'client' of undefined in SignalR

点点圈 提交于 2019-12-11 19:05:40

问题


I'm getting the error Unable to get property 'client' of undefined while accessing the hub method clientside. My code is as below:

 I have my hub like this:
    [HubName("command")]
    public class CommandHub : Hub
    {
        public void TrackStatusCommand(string serialNumber)
        {
            Groups.Add(Context.ConnectionId, serialNumber);
        }
        public void StatusCompleted(string serialNumber, bool status)
        {
            Clients.Group(serialNumber).statusCompleted(serialNumber, status);
        }
    }

    var hubProxy = $.connection.command, intervalHandle, timeout;
    $.connection.hub.logging = true;
    var priority = 0;
    var accNumber = $("#spnAccountNumber").data("templatepath");
    var model = $('#Model').text();
    hubProxy.client.statusCompleted = function (serialNumber, status) {
        $("#StatusData").css("display", "block");
        $('#StatusButton').prop('disabled', false);
        $.connection.hub.stop();
    };
    $.connection.hub.start({ transport: 'longPolling' }).done(function () {
        if ($.connection.hub.transport.name === "longPolling") {
            intervalHandle = setInterval(function () {
                statusCompleted(accNumber, model, priority, status);
            }, 30000);
        }
        hubProxy.server.trackStatusCommand(serialNumber);
        timeout = setTimeout(function () {
            $.connection.hub.stop();
            $("#StatusData").css("display", "block");
        }, 60000);
    }).fail(function () {
        $('#StatusButton').prop('disabled', false);
    });
    $.connection.hub.disconnected(function () {
        clearInterval(intervalHandle);
        clearTimeout(timeout);
    });

Once after deleting the temporary files from the root folder in the following path I'm not getting the error and it is working as expected.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

Please help. Thank you.

来源:https://stackoverflow.com/questions/23268351/unable-to-get-property-client-of-undefined-in-signalr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!