title: how to call a specific function from a hub using signalR
body: <p>I am attempting to call different javascript functions (from the server to the client!) based on what parameters the server has received.</p>
  
  <p>How can I specify which function with which parameter I would like to invoke on the clientside from the server?</p>
  
  <pre><code>public class TestData
  {
      public string function{ get; set; }
      public string element{ get; set; }
  }
  
  public class PerfHub : Hub
  {       
      public void Send(string id, string message)
      {
          if (!String.IsNullOrEmpty(id))
          {
              List&lt;TestData&gt; testList = new List&lt;TestData&gt;();
              if (id == "1")
              {
                  testList.Add(new TestData { function= "show", element= "grid" });
                  Clients.All.sendInstructions(id, testList);
              }
              else if (id == "2")
              {
                  testList.Add(new TestData { function= "hide", element= "grid" });
                  Clients.All.sendInstructions(id, testList);
              }
  </code></pre>
  
  <p>My JavaScript on a client looks like this:</p>
  
  <pre><code> $(function () {
  
      var instructions = $.connection.perfHub;
  
      // receive instructions from the server
      instructions.client.sendInstructions = function (id, message) {
  
  
          var requestedFunction = message;
  
          function show(parameters) {
              $(parameters).show();
          }
  
          show();
  
          function hide(parameters) {
              $(parameters).show();
          }
  
          hide();
  </code></pre>
  
  <p>Currently I send the id to the server using jQuery .hover method as I can't seem to get click event to work properly.</p>
  
  <pre><code>    $.connection.hub.start().done(function () {
          $('html *').hover(function () {
              // Call the Send method on the hub.
              instructions.server.send($(this).attr('id'), $(this).val());
              //$('#message').val($(this).attr('id')).focus();
          }, function () {
              $('#message').val('').focus();
          });
      });
  });
  </code></pre>
  
  <p>Thanks!</p>