title: SignalR how to call 2 different method in 1 Hub?
body: <p>So I have 2 methods in 1 hub:</p>
  
  <pre><code>public class ChatHub : Hub
  {
      public void SendMessage(string name, string message)
      {
          Clients.All.AddMessage(name, message);
      }
  
      public void SendAnnounce(string name)
      {
          Clients.Others.AddMessage(name);
      }
  }
  </code></pre>
  
  <p>How do you properly use 2 methods together in 1 hub in client side javascript?</p>
  
  <p>I have this in javascript,</p>
  
  <p>for SendMessage(string name, string message) hub method:</p>
  
  <pre><code>            var message = $("#txtMessage").val();
              var userid = $("#lblUsername").html();
              chat.client.addMessage = function (frm, msg) {
                  $messages.append("[" + frm + "] " + msg);
              }
  </code></pre>
  
  <p>invoke:</p>
  
  <pre><code>            chat.server.sendMessage(userid, input);
  </code></pre>
  
  <p>for SendAnnounce(string name) hub method:</p>
  
  <pre><code>            chat.client.addMessage = function (frm) {
                  $announcement.append("&lt;div&gt;test&lt;/div&gt;");
              }
  </code></pre>
  
  <p>invoke:</p>
  
  <pre><code>            var userid = $("#txtUsername").val();
              chat.server.announcement(userid);
  </code></pre>
  
  <p>But it doesn't work(server just uses the last method in my case announcement one).<br>
  It works only if I make 2 hubs and put each method in different hubs, then create different variables for each hub like this:</p>
  
  <pre><code>                //Create Hub on Air
              var chat = $.connection.chatHub;
              var chat2 = $.connection.announcementHub;
  </code></pre>
  
  <p>then work with 1 method with "chat" variable and with second method with "chat2" variable.. Then it works. Like this:</p>
  
  <pre><code>            chat.client.addMessage = function (frm, msg) {
                  $messages.append("[" + frm + "] " + msg);
              }
              chat2.client.addMessage = function (frm) {
                  $announcement.append("&lt;div&gt; test&lt;/div&gt;");
                  });
              }
  </code></pre>
  
  <p>What do I not understand?</p>