From cdeaa30b2f9cc575f1193e1bd0340383f23a5792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Tom=C3=A1s?= Date: Mon, 1 Oct 2018 13:24:17 +0200 Subject: [PATCH] Fixed issue webmvc signalr not notifying submitting state --- src/Web/WebMVC/Views/Shared/_Layout.cshtml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Web/WebMVC/Views/Shared/_Layout.cshtml b/src/Web/WebMVC/Views/Shared/_Layout.cshtml index 8e874bd33..37baf4ebb 100644 --- a/src/Web/WebMVC/Views/Shared/_Layout.cshtml +++ b/src/Web/WebMVC/Views/Shared/_Layout.cshtml @@ -96,24 +96,23 @@ if ('@User.Identity.IsAuthenticated' === 'True') { var timerId; - let connection = stablishConnection(); - - connection.start().then(function () { - console.log('User Registered to Signalr Hub'); - }); - - registerNotificationHandlers(connection); + stablishConnection((conn) => registerNotificationHandlers(conn)); } - function stablishConnection() { - return new signalR.HubConnectionBuilder() + function stablishConnection(cb) { + let connection = new signalR.HubConnectionBuilder() .withUrl('@settings.Value.SignalrHubUrl/hub/notificationhub', { transport: signalR.HttpTransportType.LongPolling, accessTokenFactory: () => { return "Authorization", getToken(); } }) - .build(); + .build(); + + connection.start().then(function () { + console.log('User Registered to Signalr Hub'); + cb(connection); + }); } function registerNotificationHandlers(connection) {