title: Signal R - Handling a disconnect outside of a hub
body: <p>I am trying to accomplish sending data to my client methods from a controller method that returns a response when the instance client is disconnected. </p>
  
  <p><strong>Controller</strong>
  Currently..</p>
  
  <pre><code> public void SomeMethod(){
      IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext&lt;MyHub&gt;();
  
      while(true){
           hubContext.Clients.All.addNameValue(name,value);
      }
   }
  </code></pre>
  
  <p>What I would like..</p>
  
  <pre><code> bool someProperty = false
   public string SomeMethod(){
      IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext&lt;MyHub&gt;();
  
      while(true &amp; (someProperty == false)){
           hubContext.Clients.All.addNameValue(name,value);
      }
      return "done";
   }
  </code></pre>
  
  <p>since we know a client disconnects from the hub overrided method..</p>
  
  <p><strong>Hub</strong></p>
  
  <pre><code> public override Task OnDisconnected(bool stopCalled = true)
      {
          Console.WriteLine("Hub Disconnected: {0}\n", Context.ConnectionId);
          return (base.OnDisconnected(stopCalled));
      }
  </code></pre>
  
  <p>Is there any way from outside a hub to keep track of a controller instance so that something like this can be done?</p>
  
  <pre><code>public override Task OnDisconnected(bool stopCalled = true)
      {
          SomeClass.someProperty = true;
          Console.WriteLine("Hub OnDisconnected {0}\n", Context.ConnectionId);
          return (base.OnDisconnected(stopCalled));
      }
  </code></pre>
  
  <p>We seek the ability to open a connection using signal R when we want to stream data back and forth, but the ability to know when the client disconnects so the client can continue doing things. </p>