So i have a web app running on signalR and i am using just one HTML with static header and footer and just a div to dynamically change the page content. One of the tabs that load into the div loads js file with signalR connection to the hubs, everything works fine, the js file listens to events and it fires server side methods but the issue is the server is not calling the client functions in the js file. Connection ids match and it is successfully connected to the client yet not procing the functions. The other js file i use for authenticating user is not added dynamically and works just fine.
hub method that is called correctly:
public void ClientCall()
{
IHubContext context;
context = GlobalHost.ConnectionManager.GetHubContext<LdServiceHub>();
context.Clients.Client(this.Context.ConnectionId).callbackMethod("50");
}
the js client function that doesnt fire:
$.connection.ldServiceHub.client.callbackMethod = function (item) {
console.log(item);}
and this is how i load the signalR file into the empty div:
var script = document.createElement('script');
script.src = 'Scripts/SignalRConnection.js';
script.type = 'text/javascript';
maindiv.appendChild(script);
it loads properly and connects properly, fires hub function properly but never recieves the call from server and procs a client function.
Keep in mind the script is added to the DOM dynamically and the code above is only a snippet example of the code as the src code i am using contains lot of unrelated stuff. Thanks
EDIT: thought i should mention i use Owin selfhost to host the connection, everything works fine in the user authentication js file, the only difference between those two is that the second one is added dynamically to the html