title: WCF Duplex Channel: Check if callback channel is still available
body: <p>I have the following problem. I'm writing chat software. The client/server mechanism is based on DualHttpBinding of WCF. This means that if a user sends a message, all clients that are in the room where the message has been sent, are notified by the server.</p>
  
  <p>I want to ensure, that if a client's application crashes (whyever), the client object is removed from the rooms' lists. </p>
  
  <p>Is there a possibility to check the callback channel's state before calling a callback operation? The problem is, that if i call an operation on a client which is not anymore connected (because of an unexpected crash), the service will hang.</p>
  
  <pre><code> public YagzResult SendMessage(Message message)
      {
          foreach (ChatNodeAddress chatNodeAddress in message.Destination)
          {
              ChatNode chatNode = chatProvider.FindChatNode(chatNodeAddress);
              if (chatNode != null)
              {
                  User currentUser = CurrentUser;
                  foreach (User user in chatNode)
                  {
                      //Don't notify the current client. Deadlock!
                      if (!user.Equals(currentUser))
                      {
                          //Get the callback channel here
                          IYagzClient client = GetClientByUser(user);
  
                          if (client != null)
                          {
                              //--&gt; If the client here called is not any more available,
                              //the service will hang &lt;---
                              client.OnChatMessageReceived(message);
                          }
                      }
                  }
              }
              else
              {
                  return YagzResult.ChatNodeNotFound;
              }
          }
          return YagzResult.Ok;
      }
  </code></pre>
  
  <p>How can i check if a client is still listening? BTW, the operations called on the client are all declared OneWay and the ConcurrencyMode is set to "Multiple".</p>
  
  <p>Thank you all! </p>
  
  <p>Greets, </p>
  
  <p>Simon</p>