Hi all
I have problem with signalr progressbar, update progress bar with id connection, but all progress bar updateted
Pls help me fixer problem, thanks all!
HUB
public class ChartHubs : Hub { public static string ConnectionId { get; set; } public override Task OnConnected() { ConnectionId = Context.ConnectionId; return base.OnConnected(); } }
Function update progress bar
public static void SendProgress(string progressMessage, int progressCount, int totalItems) { IHubContext progressbar = Startup.ConnectionManager.GetHubContext<ChartHubs>(); var percentage = (progressCount * 100) / totalItems; progressbar.Clients.Client(ChartHubs.ConnectionId).AddProgress(progressMessage, percentage); }
js update progress bar
$(function () { var progressbar = $.connection.chartHubs; progressbar.client.addProgress = function (mgs, percent) {$('.progress-bar').attr('aria-valuetransitiongoal', percent).progressbar({ display_text: 'fill' }); };$.connection.hub.start().done(function () { var connectionId = $.connection.hub.id; }); });
Controller update progress bar
Functions.SendProgress("processing", i + 1, listRid.Count);
Brgs!