I am able to get notified instantly when a user joins, and rejoins a group. I do not know if I am doing something wrong here, but I cannot get notified when an user leaves.
Here is the code for starting the hub on the client.
$.connection.hub.start();
Here is what I am using to stop the connection.
$.connection.hub.stop();
The stop doesn't seem to disconnect the user, so I cannot update the other users in a group and remove that connection from their session.
Client code to be called back
$.connection.hub.proxies.collaboratorhub.client.joined = function (connectionId) {
//
console.log('joined : ' + connectionId);
};
$.connection.hub.proxies.collaboratorhub.client.joined = function (connectionId) {
//
console.log('Re joined : ' + connectionId);
};
$.connection.hub.proxies.collaboratorhub.client.gone = function (connectionId) {
//
console.log('gone : ' + connectionId);
};
Here is the c# code for the server side.
public override Task OnConnected()
{
string pid = this.Context.QueryString["pid"];
Groups.Add(this.Context.ConnectionId, pid);
return Clients.Group(pid).joined(Context.ConnectionId);
}
public override Task OnDisconnected()
{
string pid = this.Context.QueryString["pid"];
Groups.Remove(Context.ConnectionId, pid);
return Clients.Group(pid).gone(Context.ConnectionId);
}
public override Task OnReconnected()
{
string pid = this.Context.QueryString["pid"];
return Clients.Group(pid).rejoined(Context.ConnectionId);
}
The join and rejoin work perfectly, but not the disconnected.
What am I missing here?