class AbstractPeerConnection implements PeerConnection {

  @Override
  public void disconnect(final DisconnectReason reason) {
    if (disconnected.compareAndSet(false, true)) {
      LOG.debug("Disconnecting ({}) from {}", reason, peerInfo);
      connectionEventDispatcher.dispatchDisconnect(this, reason, false);
      doSend(null, DisconnectMessage.create(reason));
      closeConnection();
    }
  }

  protected  AbstractPeerConnection(
      final Peer peer,
      final PeerInfo peerInfo,
      final InetSocketAddress localAddress,
      final InetSocketAddress remoteAddress,
      final String connectionId,
      final CapabilityMultiplexer multiplexer,
      final PeerConnectionEventDispatcher connectionEventDispatcher,
      final LabelledMetric<Counter> outboundMessagesCounter);

}