I have the following hub in my MVC application from where I would like to send a simple message to my client side code:
using SignalR.Hubs;
public class Progress : Hub
{
public void Send(string message)
{
// Call the addMessage method on all clients
Clients.addMessage(message);
}
public Progress()
{
Clients.addMessage("Starting to analyze image");
}
}
And the following javascript in my view
<script src="/Scripts/jquery.signalR.js" type="text/javascript"></script>
<script src="/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
// Proxy created on the fly
var connection = $.connection('/signalr/hubs/progress');
// Declare a function on the chat hub so the server can invoke it
connection.addMessage = function (message) {
$('#messages').append('<li>' + message.Content + '</li>');
};
// Start the connection
connection.start();
});
</script>
My problem is when the code calls the constructor, or the Send method for that matter, the Clients object is null.
Everything looks OK when I debug the client side code. The /signalr/hubs/ route returns javascript code and there are no errors when the javascript is run.
I can add that the backend code runs on top of the Umbraco 5 CMS environment which I am not sure is causing any disturbances.
Any suggestions on how I can debug/solve this?