I'm new to signalr. I've got a chat application working but I'll like to pass in parameters in my methods. When I pass parameters in hub, I get detail error:
at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.<>c__DisplayClass13.<OnReceived>b__10(IHub emptyHub, Object[] emptyParameters)
at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.Incoming(IHubIncomingInvokerContext context)
'Connect' method could not be resolved.`
here is my client code:
$("#btnStartChat").click(function () {
var name = $("#txtNickName").val();
var userEmail = $("#userEmail").val();
if (name.length > 0 || userEmail.length > 0) {
chatHub.server.connect(name, userEmail).fail(function (error) {
console.log('Connect error: ' + error)
});
}
else {
alert("Please enter name and email.");
}
});
Here is my Hub method:
public void Connect(string userName, string someEmail)
{
var id = Context.ConnectionId;
if (ConnectedUsers.Count(x => x.ConnectionId == id) == 0)
{
ConnectedUsers.Add(new UserDetail { ConnectionId = id, UserName = userName });
Clients.Caller.onConnected(id, userName, ConnectedUsers, CurrentMessage, someEmail);
Clients.AllExcept(id).onNewUserConnected(id, userName);
}
}
Calling all angels and guru dev saints for a healing. I've being suffering from problem for a week now! Thank you for your efforts.