title: Creating multiple hubs dynamically using SignalR
body: <p>I am currently using <code>SignalR</code> for chat. I have a form and the user will load a specific order into the form. The scenario is that other <code>staff members</code> may search that order number and therefore i want only those people to be in the chat. Currently if you load the site everyone is in a single <code>hub</code> called <code>ChatHub</code>.</p>
  
  <p><strong>ChatHub.cs:</strong></p>
  
  <pre><code>public class ChatHub: Hub {
   public void Send(string name, string message) {
    // Call the addNewMessageToPage method to update clients.
    Clients.All.addNewMessageToPage(name, message);
   }
  }
  }
  </code></pre>
  
  <p><strong>Chat.cshtml:</strong></p>
  
  <pre><code>@section scripts {
      &lt;!--Script references. --&gt;
      &lt;!--The jQuery library is required and is referenced by default in _Layout.cshtml. --&gt;
      &lt;!--Reference the SignalR library. --&gt;
      &lt;script src="~/Scripts/jquery.signalR-2.0.3.min.js"&gt;&lt;/script&gt;
      &lt;!--Reference the autogenerated SignalR hub script. --&gt;
      &lt;script src="~/signalr/hubs"&gt;&lt;/script&gt;
      &lt;!--SignalR script to update the chat page and send messages.--&gt;
      &lt;script&gt;
          $(function () {
              // Reference the auto-generated proxy for the hub.
              var chat = $.connection.chatHub;
              // Create a function that the hub can call back to display messages.
              chat.client.addNewMessageToPage = function (name, message) {
                  // Add the message to the page.
                  $('#discussion').append(htmlEncode(name)
                      + ':' + htmlEncode(message) + '\n');
              };
              // Get the user name and store it to prepend to messages.
  
              //$('#displayname').val(prompt('Enter your name:', ''));
              // Set initial focus to message input box.
              $('#message').focus();
              // Start the connection.
              $.connection.hub.start().done(function () {
                  $('#sendmessage').click(function () {
                      // Call the Send method on the hub.
                      chat.server.send($('#displayname').val(), $('#message').val());
                      // Clear text box and reset focus for next comment.
                      $('#message').val('').focus();
                  });
              });
          });
          // This optional function html-encodes messages for display in the page.
          function htmlEncode(value) {
              var encodedValue = $('&lt;div /&gt;').text(value).html();
              return encodedValue;
          }
      &lt;/script&gt;
  }
  &lt;script&gt;
  </code></pre>
  
  <p><strong>I have tried to add the following:</strong></p>
  
  <pre><code>&lt;script&gt;
  $(function () {
      var chat = jQuery.connection.chat;
  
      chat.addMessage = function (message, room) {
  
          if ($('#currentRoom').val() == room) {
              $('#messagesList').append(message);
          }
      };
  
  
          chat.send($('#textboxMessage').val(), $('#currentRoom').val());
          $('#textboxMessage').val("");
  
  
      $.connection.hub.start();
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I am trying to work out a way of getting multiple hubs or chat rooms based on a user loading an order.</p>