I have been struggling with this error for quite a while. I am trying to make signalr listen to my 2 methods. It works perfectly when I comment out the (this) methods. However, it does not work. Can anyone help me figure this out? Sometimes I can retrieve the value but then it throws an error like the one shown below in the image. I have searched through various pages but have not found any answers yet.
Vuejs
const hubConnection = new signalR.HubConnectionBuilder()
.configureLogging(signalR.LogLevel.Debug)
.withUrl("http://localhost:7002/ChatHub", {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets,
})
.build();
hubConnection.start();
this.connectionId = hubConnection.connectionId;
this.connection = hubConnection;
hubConnection.on("UserConnected",(users) => console.log(users));(this)
hubConnection.on(categoryId, (all) => {
all = JSON.parse(all);
this.userMessage = {
id: all.Id,
text: all.Text,
userId:all.UserId,
userName:all.UserName,
categoryName: all.CategoryName,
createdOn: all.CreatedOn,
};
this.messages.push(this.userMessage);
console.log(this.userMessages);
});
},
using Microsoft.AspNetCore.SignalR;
using System.Text;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.AspNetCore.Http;
using System;
... (remaining code truncated for brevity) ...
}
}
}
When I remove the OnConnectedAsync client method, everything works smoothly. Am I overlooking something?