2.3.1.OnConnected, OnDisconnected

--

  • 1.Override OnConnected(), OnDisconnected(bool stopCalled) method in hub:

          public override Task OnConnected()
          {
              return Clients.All.log("connected" + DateTime.Now.ToString());
          }
          public override Task OnDisconnected(bool stopCalled)
          {
              return Clients.All.log("Disconnected" + DateTime.Now.ToString());
          }
  • 2.Modified client side

      var obj = $.connection.myhub
      obj.client.log = function (data) {
          alert(data);
      }

Last updated