/**
   * Handles events that indicate a connection to been established between two network services and
   * prepares all objects to work with this new connection
   *
   * @param remoteComponentProfile
   */
  public final void handleEstablishedRequestedNetworkServiceConnection(
      PlatformComponentProfile remoteComponentProfile) {

    try {

      /*
       * Get the active connection
       */
      CommunicationsVPNConnection communicationsVPNConnection =
          communicationsClientConnection.getCommunicationsVPNConnectionStablished(
              platformComponentProfile.getNetworkServiceType(), remoteComponentProfile);

      // Validate the connection
      if (communicationsVPNConnection != null && communicationsVPNConnection.isActive()) {

        /*
         * Instantiate the local reference
         */
        CommunicationNetworkServiceLocal communicationNetworkServiceLocal =
            buildCommunicationNetworkServiceLocal(remoteComponentProfile);

        /*
         * Instantiate the remote reference
         */
        CommunicationNetworkServiceRemoteAgent communicationNetworkServiceRemoteAgent =
            buildCommunicationNetworkServiceRemoteAgent(communicationsVPNConnection);

        /*
         * Register the observer to the observable agent
         */
        communicationNetworkServiceRemoteAgent.addObserver(communicationNetworkServiceLocal);

        /*
         * Start the service thread
         */
        communicationNetworkServiceRemoteAgent.start();

        /*
         * Add to the cache
         */
        communicationNetworkServiceLocalsCache.put(
            remoteComponentProfile.getIdentityPublicKey(), communicationNetworkServiceLocal);
        communicationNetworkServiceRemoteAgentsCache.put(
            remoteComponentProfile.getIdentityPublicKey(), communicationNetworkServiceRemoteAgent);
      }

    } catch (final Exception e) {
      errorManager.reportUnexpectedPluginException(
          pluginVersionReference,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          e);
    }
  }
  /**
   * Handles events that indicate a connection to been established between two network services and
   * prepares all objects to work with this new connection
   *
   * @param remoteComponentProfile
   */
  public void handleEstablishedRequestedNetworkServiceConnection(
      PlatformComponentProfile remoteComponentProfile) {

    try {

      /*
       * Get the active connection
       */
      CommunicationsVPNConnection communicationsVPNConnection =
          communicationsClientConnection.getCommunicationsVPNConnectionStablished(
              platformComponentProfile.getNetworkServiceType(), remoteComponentProfile);

      // Validate the connection
      if (communicationsVPNConnection != null && communicationsVPNConnection.isActive()) {

        /*
         * Instantiate the local reference
         */
        CommunicationNetworkServiceLocal communicationNetworkServiceLocal =
            new CommunicationNetworkServiceLocal(
                remoteComponentProfile,
                errorManager,
                eventManager,
                outgoingMessageDao,
                platformComponentProfile.getNetworkServiceType());

        /*
         * Instantiate the remote reference
         */
        CommunicationNetworkServiceRemoteAgent communicationNetworkServiceRemoteAgent =
            new CommunicationNetworkServiceRemoteAgent(
                identity,
                communicationsVPNConnection,
                errorManager,
                eventManager,
                incomingMessageDao,
                outgoingMessageDao);

        /*
         * Register the observer to the observable agent
         */
        communicationNetworkServiceRemoteAgent.addObserver(communicationNetworkServiceLocal);

        /*
         * Start the service thread
         */
        communicationNetworkServiceRemoteAgent.start();

        /*
         * Add to the cache
         */
        communicationNetworkServiceLocalsCache.put(
            remoteComponentProfile.getIdentityPublicKey(), communicationNetworkServiceLocal);
        communicationNetworkServiceRemoteAgentsCache.put(
            remoteComponentProfile.getIdentityPublicKey(), communicationNetworkServiceRemoteAgent);
      }

    } catch (Exception e) {
      e.printStackTrace();
      errorManager.reportUnexpectedPluginException(
          Plugins.CHAT_NETWORK_SERVICE,
          UnexpectedPluginExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_PLUGIN,
          new Exception("Can not get connection"));
    }
  }