Signalr Uncaught TypeError: currentHub.server.OnConnected is not a function(…)
<p>I'm connecting to a sugnalr Hub using signalr javascript client. </p>

<p>The Hub OnConnected Method is this </p>

<pre><code>   public override Task OnConnected()
        {
            try
            {
                 var cType = Context.QueryString["type"];
                var connectionId = Context.ConnectionId;
                var connectedUserList = (from d in Users
                                         where d.ClientType == cType
                                                          select d).ToList();
                if (connectedUserList.Count &gt; 0)
                {
                    var conUser = connectedUserList.First&lt;ConnectedUsers&gt;();
                    conUser.ConnectionIds.Add(connectionId);
                }
                else
                {
                    var newUser = new ConnectedUsers
                    {
                        ConnectionIds = new HashSet&lt;string&gt; {connectionId}
                       ,
                        ClientType = cType
                    };
                    Users.Add(newUser);
                }
            }
            catch (Exception ex)
            {

            }
            return base.OnConnected();
        }
</code></pre>

<p>Other Hub  method</p>

<pre><code> public void PushMessage()
        {
            try
            {
                var context = GlobalHost.ConnectionManager.GetHubContext&lt;MainHub&gt;();
                   var user = (from d in Users
                                       where d.ClientType == "WIN"
                                       select d).Single();
                context.Clients.Clients(user.ConnectionIds.ToArray()).sendAlert("EXCEL");
            }
            catch (Exception e)
            {
                //throw;
            }
        }
</code></pre>

<p>And the Javascript client connect code as below</p>

<pre><code>&lt;html&gt;
&lt;body&gt;
    @RenderBody()

    @Scripts.Render("~/bundles/jquery")
    &lt;script src="~/Scripts/jquery.signalR-2.2.1.js"&gt;&lt;/script&gt;
    &lt;script src="@Url.Content("http://localhost:1010/signalr/hubs")"&gt;&lt;/script&gt; 
    @RenderSection("scripts", required: false)
&lt;/body&gt;
&lt;/html&gt;


&lt;script type="text/javascript"&gt;

    var currentHub = [];
    var connectionDetails = {};
    var SignalRHandler = {
        _settings: {
            connectionDetails: {
                id: "1",
                userName: ""
            },
            hub: $(),
            callBack: $(),
            url: ""
        },

        initilaize: function(options) {
            this._settings = $.extend(true, this._settings, options);
            if (!$.connection)
                alert("$.connection undefined");
            else
                this._bindEvents();
        },

        _bindEvents: function() {
            // Start Hub
            $.connection.hub.url = this._settings.url;
            $.connection.hub.qs = { 'type': 'WEB' }
            currentHub = $.connection[this._settings.hub], connectionDetails = this._settings.connectionDetails;

            if (currentHub != undefined) {

                currentHub.client.sendAlert = this._settings.callBack;

                $.connection.hub.start().done(function() {
                    currentHub.server.OnConnected();

                });
                $.connection.hub.disconnected(function() {
                    setTimeout(function() {
                        $.connection.hub.start().done(function() {
                            currentHub.server.OnConnected();
                        });
                    }, 2000); // Restart connection after 2 seconds.
                });
            }

        },
        pushChatMessage: function () {
            currentHub.server.pushMessage();
        },
        showMsg:function(msg) {
            alert(msg);
        }
    };
    jQuery(document).ready(function($) {

        SignalRHandler.initilaize({
            callBack: SignalRHandler.showMsg,
            hub: "mainHub",
            url: "http://localhost:1010/signalr/"

        });

    });
&lt;/script&gt;
</code></pre>

<p>This code is working perfectly and connecting to the hub and receive messages from the hub continuously. 
But when I check the debugger console it says.</p>

<blockquote>
  <p>Uncaught TypeError: currentHub.server.OnConnected is not a function(…)</p>
</blockquote>

<p>How to get rid of this error?</p>