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,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) {