0

why hub object is undefined below is the code, I have owin, hub all the classes in my project, howevery am not able to call hub methods?

    <!--Reference the SignalR library. -->


    <script src="../scripts/jquery.signalR-2.2.1.min.js"></script>

    <!--Reference the autogenerated SignalR hub script. -->
    <script src="/signalr/signalr/hubs"></script>
   <script type="text/javascript">
    $(function () {

        //why hub is not created matrixHub = undefined
        var matrixHub = $.connection.MyHub;

        // TODO, callbacks and hub invoker

        $.connection.hub.start();
        debugger;
    });
</script>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
bilal
  • 648
  • 8
  • 26

1 Answers1

1

Your capitalization is wrong, it should be

var matrixHub = $.connection.myHub;

IF your hub class is named MyHub : Hub

The reason for this has to do with how the javascript for the hub is generated, all methods and the hub itself are all created with camelCase names on a javascript client.

Kelso Sharp
  • 972
  • 8
  • 12