0

I have a self-hosted application akin to a scenario wherein I have a method that continuously broadcasts to groups (whether somebody has "joined" or not). Something like:

var aTimer = new System.Timers.Timer(2000);
aTimer.Elapsed += (sender, e) =>
{
  // broadcast to listeners whether they are listening or not
  IHubConnectionContext _clients = GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients;

  _clients.Group("group1FixedName").showMessage("Some message for group 1 only");       
  _clients.Group("group2FixedName").showMessage("Some message for group 2 only");       
  // etc
};
aTimer.Start(); 

I had recently upgraded to version 1.1.0 from beta1. I started to observe that the "remove" method doesn't work as the "client" (web browser) is still receiving messages from the "other" group even if I initiated a "leave". Note that "leaving" the group doesn't mean closing the web browser. It's still in the same page (Single Page Application) and leaving/joining a group is triggered by a selection (combo box for example).

Code in hub:

public Task Leave(string groupName)
{
        return Groups.Remove(Context.ConnectionId, groupName)
               .ContinueWith(z => Clients.Caller.showCallerMessage("You are now leaving " + groupName));

}

Code in javascript client to "leave the group":

chat.server.leave("group1FixedName");

Code in javascript client to "join the group":

chat.server.join("group1FixedName");

Code in Hub for joining:

public Task Join(string groupName)
{
        return Groups.Add(Context.ConnectionId, groupName)
               .ContinueWith(z => Clients.Caller.showCallerMessage("You are now listening to " + groupName));

}

Is there something wrong with my implementation here?

alpinescrambler
  • 1,934
  • 16
  • 26
  • The snippets you show look fine. Can you make a sample application and put it on github? – davidfowl May 15 '13 at 18:29
  • Thanks @dfowler, I'll make a scaled down version of my application, and make sure I replicate the issue first. – alpinescrambler May 15 '13 at 18:33
  • I uploaded the sample applications here: https://github.com/ericpanorel/SignalrDebugForDfowler While debugging, I found that the beta bits on the self-host application still worked (no problem), even if I had the latest bits for the client. When I upgraded the bits for the self-hosted app as well, the problem described appears already. – alpinescrambler May 15 '13 at 20:48

1 Answers1

0

This is bug #2040 introduced in 1.1.0beta. Team is working on fixing it.

Gustavo Armenta
  • 1,525
  • 12
  • 14