title: SignalR not calling client methods from the server
body: <p>I'm adding all my client methods before I call .start().</p>
  
  <p>What I'm doing is loading wiring up all the client methods and I've got a setTimeout for 5 seconds to actually call .start(), so I know all my client script is wired up.</p>
  
  <p>For some reason the scripted gets wired up but will not be called be the server.</p>
  
  <p>Now, I'm able to call the server methods with no problems, I just need the server to relay that message back to the clients, via the client script.</p>
  
  <p>Is it OK to put client script inside named function objects?</p>
  
  <p>I've removed a lot of the code so it is readable.</p>
  
  <p><strong>This works, because I'm calling the server.</strong></p>
  
  <pre><code>$.connection.hub.proxies.collaboratorhub.server.sendMsg
  </code></pre>
  
  <p>-</p>
  
  <p><strong>This does not work because I'm waiting on the server to send the client it's message</strong></p>
  
  <pre><code> $.connection.hub.proxies.collaboratorhub.client.receiveMsg 
  </code></pre>
  
  <p>=</p>
  
  <p><strong>On the server side when I debug I am receiving the sentMsg from the client to the server and the receiveMsg is being called from the server, but it never makes it to the client.</strong></p>
  
  <pre><code>    function ChatBox(collaboratorMenuItem) {
  
      var 
          sendMsg = function (ev) {
              // If the user has pressed enter
  
              if (ev.keyCode === 13) {
  
                  if (this.value.trim() === '') { return false; };
  
                  var avatar = attendees.querySelector('.' + meAttendee.profile.UserID);
                  if (avatar) {
  
                      chats.appendChild(
                             docCreateAttrs('div', { 'class': 'collabChat', innerHTML: this.value }).addChild(avatar.cloneNode(true))
                             );
                  } else {
                      chats.appendChild(
                            docCreateAttrs('div', { 'class': 'collabChat', innerHTML: this.value })
                            );
                  };
  
                  $.connection.hub.proxies.collaboratorhub.server.sendMsg({ msg: this.value });
  
                  this.value = '';
                  return false;
              } else { return true; };
          },
  
  
  
      debugger
      //Callbacks that are called from the server. Not intended for local function calls
      $.connection.hub.proxies.collaboratorhub.client.receiveMsg = function (cmsg) {
  
          var avatar = attendees.querySelector('.' + cmsg.uid);
          if (avatar) {
  
              chats.appendChild(
                     docCreateAttrs('div', { 'class': 'collabChat', innerHTML: cmsg.msg }).addChild(avatar.cloneNode(true))
                     );
          } else {
              chats.appendChild(
                    docCreateAttrs('div', { 'class': 'collabChat', innerHTML: cmsg.msg })
                    );
          };
      };
      $.connection.hub.proxies.collaboratorhub.client.addCurrAttendee = function (attendee) {
  
          debugger
          addAttendee(attendee);
      };
      $.connection.hub.proxies.collaboratorhub.client.joined = function (attendee) {
          debugger
          addAttendee(attendee);
  
          //let the new attendee know about you
          if (attendee.cnnid !== meAttendee.cnnid) {
              meAttendee.newbieid = attendee.cnnid;
              //
              this.server.addMeNewbie(meAttendee);
          };
      };
      $.connection.hub.proxies.collaboratorhub.client.rejoined = function (attendee) {
          debugger
          //console.log('Re joined : ' + attendee.cnnid);
          addAttendee(attendee);
  
          //let the new attendee know about you
          if (attendee.cnnid !== meAttendee.cnnid) {
  
              meAttendee.newbieid = attendee.cnnid;
              this.server.addMeNewbie(meAttendee);
          };
      };
      $.connection.hub.proxies.collaboratorhub.client.gone = function (attendee) {
          // console.log('gone : ' + attendee.cnnid);
          removeAttendee(attendee);
      };
  
      collaboratorMenuItem.onclick = function (e) {
          //debugger
          if (!chatBox.parentNode) {
              var xy = e.target.getBoundingClientRect();
  
              document.body.appendChild(chatBox.setGX(null, xy.left).setGY(null, xy.height));
              $(chatBox).draggable({ handle: chatHead, cursor: "move" }).css('position', 'absolute').resizable();
          } else {
              removeChat();
          };
      };
  
      return {
          chatBox: chatBox,
          attendLk: attendLk,
          addAttendee: addAttendee,
          removeAttendee: removeAttendee,
          removeChat: removeChat
      };
  };
  </code></pre>
  
  <p>--This is how I create a name function called <code>collaborateManager</code> that when instantiated has a property call <code>this.chatBox</code> and this is where all the client script is loaded up, with-in the <code>ChatBox</code>.</p>
  
  <p>The collaboratorMenuItem is just a div that the ChatBox is placed next to.</p>
  
  <pre><code>  function collaborateManager(collaboratorMenuItem) {
  
  
  
                  this.chatBox = new ChatBox(collaboratorMenuItem);
  
  
      }
  
  
      return {
          hideCollaborator: hideCollaborator,
          showCollaborator: showCollaborator,
          getCollaborator: getCollaborator,
          removeCollaboratorCollaborators: removeCollaborator
      };
  </code></pre>
  
  <hr>
  
  <p>And in another Global JS File I start the connect in five seconds.</p>
  
  <pre><code>document.bindReady(function () {
  
  setTimeout(function () {
  
      //Global SignalR Connections State
  
      var cnnStateChanged = function (change) {
  
          if (change.newState === $.signalR.connectionState.reconnecting) {
              console.log('Re-connecting');
          }
          else if (change.newState === $.signalR.connectionState.connected) {
  
              console.log('The server is online');
          }
          else if (change.newState === $.signalR.connectionState.disconnected) {
  
              console.log('The server is offline');
          };
      },
       cnnReconnected = function (change) {
  
           if (change &amp;&amp; change.newState === $.signalR.connectionState.reconnected) {
  
           };
           console.log('The server is re-connected');
       };
      //------------------------------------------------------------------------------------------------------------
      //Global start SignalR connectio
  
      $.connection.hub.stateChanged(cnnStateChanged);
      $.connection.hub.reconnected(cnnReconnected);
  
      if ($.connection.hub &amp;&amp; $.connection.hub.state === $.signalR.connectionState.disconnected) {
          $.connection.hub.start().done(function () {
  
              //debugger
              // onConnected();
          });
      } else {
          //debugger
          // onConnected();
      };
  
  },5000);
  </code></pre>
  
  <p>});</p>
  
  <hr>
  
  <p>The connection is starting correctly each time, that is not the issue, I can send server messages as well, I need to be able to receive those messages.</p>
  
  <p><strong>Here is my server side sendMsg that gets called, but no clients ever receive the receiveMsg()</strong></p>
  
  <pre><code>  public Task sendMsg(Cmsg cmsg)
      {
          string pid = this.Context.QueryString["pid"],
                 uid = this.Context.QueryString["uid"];
          //
          cmsg.cnnid = Context.ConnectionId;
          cmsg.uid = uid;
          //614
  
          return Clients.OthersInGroup(pid).receiveMsg(cmsg);
      }
  </code></pre>
  
  <p>Any suggestions? Am I doing this wrong?</p>