locked
Wpf client and asp.net web app signalr Hub , save users list logged in from wpf client in signalr hub RRS feed

  • Question

  • I am creating signalr hub in asp.net web app

    My wpf application is client for this signalr hub

    I have login facility in my wpf application , I want to store this users on hub created in asp.net , so that I can send information to specific user . I want to store two properties UserName and UserToken , the list of these properties in hub , How I can send this properties information to hub

    I tried using Client.Caller but its not getting any value in connected or disconnected event on hub

    any suggestions?

    How I can do this?


    Ramesh

    Thursday, June 4, 2015 1:47 PM

Answers

  • Been a while since I used SignalR.... but IIRC...

    You can use query string parameters, handing them over as a Dictionary<string, string>

    Key and value.

    And this page here http://www.asp.net/signalr/overview/guide-to-the-api/hubs-api-guide-net-client

    Seems to confirm my recall.

    var querystringData = new Dictionary<string, string>();
    querystringData.Add("contosochatversion", "1.0");
    var connection = new HubConnection("http://contoso.com/", querystringData);

    and

    public class StockTickerHub : Hub
    {
        public override Task OnConnected()
        {
            var version = Context.QueryString["contosochatversion"];
            if (version != "1.0")
            {
                Clients.Caller.notifyWrongVersion();
            }
            return base.OnConnected();
        }
    }


    Hope that helps.

    Technet articles: WPF: Change Tracking; All my Technet Articles

    Thursday, June 4, 2015 3:01 PM