var connection = new HubConnection("http://localhost:8080"); var chatHubProxy = connection.CreateHubProxy("ChatHub"); chatHubProxy.On("broadcastMessage", (name, message) => { Console.WriteLine("{0}: {1}", name, message); }); await connection.Start(); chatHubProxy.Invoke("SendMessage", "John", "Hello");
var connection = new HubConnection("http://localhost:8080"); var stockTickerProxy = connection.CreateHubProxy("StockTickerHub"); stockTickerProxy.OnIn this example, a connection is established to the SignalR server. Then a hub proxy for the "StockTickerHub" is created. The "stockUpdated" event is registered to handle incoming stock updates from the server and print them to the console. Finally, the client subscribes to receive updates for the "AAPL", "GOOG", and "AMZN" stocks using the "SubscribeStocks" method. Package library: Microsoft.AspNet.SignalR.Client.("stockUpdated", (stock) => { Console.WriteLine("{0}: {1}", stock.Name, stock.Price); }); await connection.Start(); stockTickerProxy.Invoke("SubscribeStocks", "AAPL", "GOOG", "AMZN");