0

I am just starting with SignalR and I am using version 1.2.0. I do have an existing asp.net webform application where users signs in and does some activities and signs out or just closes the browser.

Can anybody please share any code sample so that whenever the users signs in, after validating the credentials when he logs in the system the information is passed to the Dashboard

Update : I am trying to utilize the code in this example : http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-server-broadcast-with-signalr-20

What I am trying to get the Singleton object and add a new stock[my case would be user] to it.But it seems I can't get the Sigleton object when I try in the login page as bellow :

        StockTiker s = StockTiker.Instance;
        s.AddStock(new Stock{});
marifrahman
  • 681
  • 2
  • 13
  • 31

1 Answers1

1

After a user is signed in the Hub is notified via OnConnected() , and when a user disconnected via OnDisconnected() . You can do something like this to update a dashboard :

public class MyHub : Hub
{
    public Task OnConnected()
    {
      // Send stuff to dashboard
      return base.OnConnected();
    }

    public Task  OnDisconnected()
    {
      // Send stuff to dashboard
      return base.OnDisconnected();
    }
}
Shachaf.Gortler
  • 5,655
  • 14
  • 43
  • 71
  • That's the code for the hub; When a user is loggin in from a page how can I call the hub and OnConnect from the serverside code ? – marifrahman Feb 13 '14 at 23:49