Marianne Markwardt
Marianne Markwardt

Reputation: 131

SignalR doesn't reach JS client function

I can successfully call testFunc() on my server. But the Invoke simply never gets to my testFuncCallback() function. Since I can call the server, the connection appears to be fine. Any idea what's going on?

BACKEND:

[HubName("testHub")]
public class testHub: Hub
{
    public void testFunc()
    {
        Clients.Caller.Invoke("testFuncCallback");
    }
}

JS:

$scope.lTestHub = $scope.$parent.signalrConnection.testHub;
$scope.lTestHub.on('testFuncCallback', function () {
    alert("jo");
});
$scope.lTestHub.server.testFunc();

Upvotes: 1

Views: 78

Answers (1)

DDan
DDan

Reputation: 8276

Change the line

$scope.lTestHub.on('testFuncCallback', function () {

to

$scope.lTestHub.client('testFuncCallback', function () {

That should do it.

See simple example here: http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr

Upvotes: 1

Related Questions