Fixed issue webmvc signalr not notifying submitting state

This commit is contained in:
Ramón Tomás 2018-10-01 13:24:17 +02:00
parent ad76fa01ad
commit cdeaa30b2f

View File

@ -96,17 +96,11 @@
if ('@User.Identity.IsAuthenticated' === 'True') { if ('@User.Identity.IsAuthenticated' === 'True') {
var timerId; var timerId;
let connection = stablishConnection(); stablishConnection((conn) => registerNotificationHandlers(conn));
connection.start().then(function () {
console.log('User Registered to Signalr Hub');
});
registerNotificationHandlers(connection);
} }
function stablishConnection() { function stablishConnection(cb) {
return new signalR.HubConnectionBuilder() let connection = new signalR.HubConnectionBuilder()
.withUrl('@settings.Value.SignalrHubUrl/hub/notificationhub', { .withUrl('@settings.Value.SignalrHubUrl/hub/notificationhub', {
transport: signalR.HttpTransportType.LongPolling, transport: signalR.HttpTransportType.LongPolling,
accessTokenFactory: () => { accessTokenFactory: () => {
@ -114,6 +108,11 @@
} }
}) })
.build(); .build();
connection.start().then(function () {
console.log('User Registered to Signalr Hub');
cb(connection);
});
} }
function registerNotificationHandlers(connection) { function registerNotificationHandlers(connection) {