i am getting this error Error: Failed to invoke 'MoveLobbyCard' due to an error on the server. when trying to perform an action in lobby my js code:
"use strict";
var connection = new signalR.HubConnectionBuilder().withUrl("/hub").build();
connection.start().then(function () {
}).catch(function (err) {
return console.error(err.toString());
});
connection.on("UserConnected", function (ConnectionId) {
$("#userlist").append($("<li>").text(ConnectionId + "has joined"));
var lobbyID = $('#lobbyID').text();
connection.invoke("JoinLobby", lobbyID).catch(function (err) {
return console.error(err.toString());
});
});
connection.on("CardMoved", function (id) {
$('#'+id).addClass("moved");
});
$('.card').on("click", function (){
var id = $(this).attr("id");
connection.invoke("MoveLobbyCard",id,lobbyID).catch(function (err) {
return console.error(err.toString());
});
});
it does add to groups but i have no idea whats causing the error
For me the error was caused by a method signature on the hub expecting an integer but javascript providing it (a number) as a string. I changed the hub to accept a string and parsed it to an integer before use and it was all good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With