Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit cdeaa30

Browse files
author
Ramón Tomás
committed
Fixed issue webmvc signalr not notifying submitting state
1 parent ad76fa0 commit cdeaa30

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/Web/WebMVC/Views/Shared/_Layout.cshtml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,23 @@
9696
if ('@User.Identity.IsAuthenticated' === 'True') {
9797
var timerId;
9898
99-
let connection = stablishConnection();
100-
101-
connection.start().then(function () {
102-
console.log('User Registered to Signalr Hub');
103-
});
104-
105-
registerNotificationHandlers(connection);
99+
stablishConnection((conn) => registerNotificationHandlers(conn));
106100
}
107101
108-
function stablishConnection() {
109-
return new signalR.HubConnectionBuilder()
102+
function stablishConnection(cb) {
103+
let connection = new signalR.HubConnectionBuilder()
110104
.withUrl('@settings.Value.SignalrHubUrl/hub/notificationhub', {
111105
transport: signalR.HttpTransportType.LongPolling,
112106
accessTokenFactory: () => {
113107
return "Authorization", getToken();
114108
}
115109
})
116-
.build();
110+
.build();
111+
112+
connection.start().then(function () {
113+
console.log('User Registered to Signalr Hub');
114+
cb(connection);
115+
});
117116
}
118117
119118
function registerNotificationHandlers(connection) {

0 commit comments

Comments
 (0)