Connect / Disconnect SignalR Hub

Also discovered this as a problem here , but hope someone saw it.

I have a very simple hub that implements IConnected / IDisconnect. In a stand-alone project, this hub went fine.

When I lowered it to my real project, where I already had other hubs, adding it, there were no available hubs (it was confirmed that there are no hubs in / signalr / hubs). Then I commented on IConnected / IDisconnect in this hub and recompiled it, and it appeared along with the others. Adding interfaces back broke everything.

Has anyone seen this before? Is there some kind of configuration missing or something else?

public class ChatHub : Hub, IConnected, IDisconnect
{
    public void Test(string message)
    {

    }

    public System.Threading.Tasks.Task Connect(IEnumerable<string> groups)
    {
        this.Clients.onNewUserOnline(Context.ConnectionId);
        return new Task(() => { });
    }


    public Task Reconnect(IEnumerable<string> groups)
    {
        this.Clients.onNewUserOnline(Context.ConnectionId);
        return new Task(() => { });
    }

    public Task Disconnect()
    {
        this.Clients.onUserOffline(Context.ConnectionId);
        return new Task(() => { });
    }
}
+5
source share
1 answer

Signalr?

Connection State SignalR 0.5.1

SignalR , . Weve stateChanged JavaScript .NET. -. , , 10 :

var chat = $.connection.chat;
var timeout = null;
var interval = 10000;
chat.addMessage = function (msg) {
    $('#messages').append('<li>' + msg + '</li>');
};
$.connection.hub.stateChanged(function (change) {
    if (change.newState === $.signalR.connectionState.reconnecting) {
        timeout = setTimeout(function () {
            $('#state').css('backgroundColor', 'red')
                .html('The server is unreachable...');
        }, interval);
    } else if (timeout && change.newState === $.signalR.connectionState.connected) {
        $('#state').css('backgroundColor', 'green')
            .html('The server is online');
        clearTimeout(timeout);
        timeout = null;
    }
});
$.connection.hub.start();
+7

All Articles