title: Best way to remove actor from its watcher
body: <p>I write websocket game with play framework and akka. I try implement removing Players from its manager. <code>Player</code> actor represent player state with connection. </p>
  
  <pre class="lang-java prettyprint-override"><code>public class Player extends UntypedActor {
  
      private final String openId;
      private final ActorRef out;
  
      public Player(String openId, ActorRef out) {
          this.openId = openId;
          this.out = out;
      }
  
      @Override
      public void preStart() throws Exception {
          Application.clientManager.tell(
            new ClientsManager.PlayerConnectedMessage(openId, self()), self()
          );
      }
  
      @Override
      public void postStop() throws Exception {
          //may be tell my id here?
      }
  }
  </code></pre>
  
  <p>when it creates, player registers in manager actor from <code>prestart</code>. When connection closes, <code>Player</code> destroys. I need remove it from manager</p>
  
  <pre class="lang-java prettyprint-override"><code>public class ClientManager extends UntypedActor {
  
      private static Map&lt;String, ActorRef&gt; clients = new HashMap&lt;&gt;();
  
      @Override
      public void onReceive(Object message) throws Exception {
  
          if (message instanceof PlayerConnectedMessage) {
              final PlayerConnectedMessage connectedMessage = (PlayerConnectedMessage) message;
              context().watch(connectedMessage.client);
              clients.put(
                connectedMessage.id,
                connectedMessage.client
              );
          } else if (message instanceof Terminated) {
              final ActorRef toDelete = ((Terminated) message).actor();
              //How remove, i have only ActorRef
              clients.remove(...);
          }
      }
  
      public static class PlayerConnectedMessage {
          private final String id;
          private final ActorRef client;
  
          public PlayerConnectedMessage(String id, ActorRef client) {
              this.id = id;
              this.client = client;
          }
      }   
  }
  </code></pre>
  
  <p>In my architecture I want store clients with <code>Map&lt;String, ActorRef&gt;</code>, where <code>String</code> - id from may logic. Because of this I can't remove client in <code>Terminated</code> message - i have only <code>ActorRef</code>.</p>
  
  <p>Possible solution: tell <code>Disconnect</code> message to manager from <code>Player</code>'s <code>postStop</code> with it's id and not use <code>watch</code> anymore.</p>
  
  <p>Is there a elegant solution with 'watch' way, or solution with <code>postStop()</code> also good. I worry about possible clients leaking.</p>