Reputation: 33
I am trying to get all connected users with Identity but it says the error as title which is : Uncaught TypeError: signalR.httpConnection is not a constructor
For this line :
let hubUrl = '/chatHub'
let httpConnection = new signalR.httpConnection(hubUrl);
let hubConnection = new signalR.hubConnection(httpConnection);
hubConnection.on('SetUsersOnline', usersOnline => {
if (usersOnline.length > 0) {
$('#onlineUsers').innerText = '';
$.each(usersOnline, function (i, user) {
addUserOnline(user);
});
}
});
hubConnection.start();
Upvotes: 0
Views: 2297
Reputation: 4511
Syntax for SignalR was changed quite often and it's hard to tell what is and isn't correct for what version. Just update to latest SignalR and try this:
const connection = new signalR.HubConnectionBuilder()
.withUrl("/chatHub")
.configureLogging(signalR.LogLevel.Information)
.build();
connection.on('SetUsersOnline', usersOnline => {
if (usersOnline.length > 0) {
$('#onlineUsers').innerText = '';
$.each(usersOnline, function (i, user) {
addUserOnline(user);
});
}
});
connection.start().catch(err => console.error(err.toString()));
Upvotes: 2