title: Adding a user to Hub group in SignalR
body: <p>I have a base hub (HubBase) class and two different hub classes (let's call HubA and HubB) that inherited from base class. I keep all the shared connection methods to HubBase. I want to send message only the corresponding clients connected to the related hub. For this reason I will add the related user to the corresponding group on connected. For example if a user connects to HubA, this user should be added GroupA, and if connects to HubB, should be added GroupB similarly. Here are the methods in the related classes below:</p>
  
  <p><strong>HubBase:</strong></p>
  
  <pre><code>public class HubBase : Hub
  {
      public readonly static ConnectionMapping&lt;string&gt; _connections =
          new ConnectionMapping&lt;string&gt;();
  
      public override async Task OnConnected()
      {
          /* !!! Here I need the user to the given group name. But I cannot define groupName 
          parameter in this method due to "no suitable method found to override" error */
          await Groups.Add(Context.ConnectionId, "groupA");
  
          string name = Context.User.Identity.Name;
          _connections.Add(name, Context.ConnectionId);
          await base.OnConnected();
      }
  
      public override async Task OnDisconnected(bool stopCalled)
      {
          await Groups.Remove(Context.ConnectionId, "groupA");
  
          string name = Context.User.Identity.Name;
          _connections.Remove(name, Context.ConnectionId);
          await base.OnDisconnected(stopCalled);
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>HubA:</strong></p>
  
  <pre><code>public class HubA : HubBase
  {
      private static IHubContext context = GlobalHost.ConnectionManager.GetHubContext&lt;HubA&gt;();
  
      public async Task SendMessage(string message)
      {
          await context.Clients.Group("groupA", message).sendMessage;
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>HubB:</strong></p>
  
  <pre><code>public class HubB : HubBase
  {
      private static IHubContext context = GlobalHost.ConnectionManager.GetHubContext&lt;HubB&gt;();
  
      public async Task SendMessage(string message)
      {
          await context.Clients.Group("groupB", message).sendMessage;
      }
  }
  </code></pre>
  
  <p>The problem is that: I need to pass group name to the OnConnected() method in base class and add the user to this given group on connection. But I cannot define groupName parameter in this method due to "no suitable method found to override" error. Should I pass this parameter to the base Class's constructor from inherited classes? Or is there a smarter way? </p>
  
  <p><strong>Update:</strong> Here is what I tried to pass from client side:</p>
  
  <p><strong>HubService.ts:</strong></p>
  
  <pre><code>export class HubService {
      private baseUrl: string;
      private proxy: any;
      private proxyName: string = 'myHub';
      private connection: any;         
  
      constructor(public app: AppService) {
          this.baseUrl = app.getBaseUrl();
          this.createConnection();
          this.registerOnServerEvents();
          this.startConnection();
      }
  
      private createConnection() {
          // create hub connection
          this.connection = $.hubConnection(this.baseUrl);
  
          // create new proxy as name already given in top  
          this.proxy = this.connection.createHubProxy(this.proxyName);
      }
  
      private startConnection(): any {
          this.connection
              .start()
              .done((data: any) =&gt; {
                  this.connection.qs = { 'group': 'GroupA' };
              })
      }
  }
  </code></pre>
  
  <p><strong>HubBase.cs:</strong></p>
  
  <pre><code>public override async Task OnConnected()
  {
      var group = Context.QueryString["group"]; // ! this returns null
      await Groups.Add(Context.ConnectionId, group);
  
      string name = Context.User.Identity.Name;
      _connections.Add(name, Context.ConnectionId);
      await base.OnConnected();
  }
  </code></pre>