org.fourthline.cling.support.connectionmanager

## Class AbstractPeeringConnectionManagerService

- java.lang.Object
- - org.fourthline.cling.support.connectionmanager.ConnectionManagerService
  - - org.fourthline.cling.support.connectionmanager.AbstractPeeringConnectionManagerService

-     public abstract class AbstractPeeringConnectionManagerService
      extends ConnectionManagerService

  Support for setup and teardown of an arbitrary number of connections with a manager peer.
  Author:
    Christian Bauer, Alessio Gaeta

- - ### Field Summary

    - ### Fields inherited from class org.fourthline.cling.support.connectionmanager.ConnectionManagerService

      `activeConnections, propertyChangeSupport, sinkProtocolInfo, sourceProtocolInfo`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractPeeringConnectionManagerService(ConnectionInfo... activeConnections)`
    `protected` | `AbstractPeeringConnectionManagerService(PropertyChangeSupport propertyChangeSupport, ProtocolInfos sourceProtocolInfo, ProtocolInfos sinkProtocolInfo, ConnectionInfo... activeConnections)`
    `protected` | `AbstractPeeringConnectionManagerService(ProtocolInfos sourceProtocolInfo, ProtocolInfos sinkProtocolInfo, ConnectionInfo... activeConnections)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `closeConnection(ConnectionInfo connectionInfo)`
    `void` | `closeConnectionWithPeer(ControlPoint controlPoint, Service peerService, ConnectionInfo connectionInfo)` Close the connection with the peer, remove the connection details.
    `void` | `closeConnectionWithPeer(ControlPoint controlPoint, Service peerService, int connectionID)` Close the connection with the peer, remove the connection details.
    `void` | `connectionComplete(int connectionID)`
    `protected abstract ConnectionInfo` | `createConnection(int connectionID, int peerConnectionId, ServiceReference peerConnectionManager, ConnectionInfo.Direction direction, ProtocolInfo protocolInfo)`
    `int` | `createConnectionWithPeer(ServiceReference localServiceReference, ControlPoint controlPoint, Service peerService, ProtocolInfo protInfo, ConnectionInfo.Direction direction)` Generate a new local connection identifier, prepare the peer, store connection details.
    `protected int` | `getNewConnectionId()`
    `protected abstract void` | `peerFailure(ActionInvocation invocation, UpnpResponse operation, String defaultFailureMessage)` Called when connection creation or closing with a peer failed.
    `ConnectionInfo` | `prepareForConnection(ProtocolInfo remoteProtocolInfo, ServiceReference peerConnectionManager, int peerConnectionId, String direction)`
    `protected void` | `removeConnection(int connectionID)`
    `protected void` | `storeConnection(ConnectionInfo info)`

    - ### Methods inherited from class org.fourthline.cling.support.connectionmanager.ConnectionManagerService

      `getCurrentConnectionIDs, getCurrentConnectionInfo, getPropertyChangeSupport, getProtocolInfo, getSinkProtocolInfo, getSourceProtocolInfo`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractPeeringConnectionManagerService

          protected AbstractPeeringConnectionManagerService(ConnectionInfo... activeConnections)

    - #### AbstractPeeringConnectionManagerService

          protected AbstractPeeringConnectionManagerService(ProtocolInfos sourceProtocolInfo,
                                                 ProtocolInfos sinkProtocolInfo,
                                                 ConnectionInfo... activeConnections)

    - #### AbstractPeeringConnectionManagerService

          protected AbstractPeeringConnectionManagerService(PropertyChangeSupport propertyChangeSupport,
                                                 ProtocolInfos sourceProtocolInfo,
                                                 ProtocolInfos sinkProtocolInfo,
                                                 ConnectionInfo... activeConnections)

  - ### Method Detail

    - #### getNewConnectionId

          protected int getNewConnectionId()

    - #### storeConnection

          protected void storeConnection(ConnectionInfo info)

    - #### removeConnection

          protected void removeConnection(int connectionID)

    - #### prepareForConnection

          public ConnectionInfo prepareForConnection(ProtocolInfo remoteProtocolInfo,
                                            ServiceReference peerConnectionManager,
                                            int peerConnectionId,
                                            String direction)
                                              throws ActionException

      Throws:
        `ActionException`

    - #### connectionComplete

          public void connectionComplete(int connectionID)
                                  throws ActionException

      Throws:
        `ActionException`

    - #### createConnectionWithPeer

          public int createConnectionWithPeer(ServiceReference localServiceReference,
                                     ControlPoint controlPoint,
                                     Service peerService,
                                     ProtocolInfo protInfo,
                                     ConnectionInfo.Direction direction)

      Generate a new local connection identifier, prepare the peer, store connection details.
      Returns:
        `-1` if the `peerFailure(org.fourthline.cling.model.action.ActionInvocation, org.fourthline.cling.model.message.UpnpResponse, String)` method had to be called, otherwise the local identifier of the established connection.

    - #### closeConnectionWithPeer

          public void closeConnectionWithPeer(ControlPoint controlPoint,
                                     Service peerService,
                                     int connectionID)
                                       throws ActionException

      Close the connection with the peer, remove the connection details.
      Throws:
        `ActionException`

    - #### closeConnectionWithPeer

          public void closeConnectionWithPeer(ControlPoint controlPoint,
                                     Service peerService,
                                     ConnectionInfo connectionInfo)
                                       throws ActionException

      Close the connection with the peer, remove the connection details.
      Throws:
        `ActionException`

    - #### createConnection

          protected abstract ConnectionInfo createConnection(int connectionID,
                                        int peerConnectionId,
                                        ServiceReference peerConnectionManager,
                                        ConnectionInfo.Direction direction,
                                        ProtocolInfo protocolInfo)
                                                      throws ActionException

      Throws:
        `ActionException`

    - #### closeConnection

          protected abstract void closeConnection(ConnectionInfo connectionInfo)

    - #### peerFailure

          protected abstract void peerFailure(ActionInvocation invocation,
                         UpnpResponse operation,
                         String defaultFailureMessage)

      Called when connection creation or closing with a peer failed.

      This is the failure result of an action invocation on the peer's connection management service. The execution of the `createConnectionWithPeer(org.fourthline.cling.model.ServiceReference, org.fourthline.cling.controlpoint.ControlPoint, org.fourthline.cling.model.meta.Service, org.fourthline.cling.support.model.ProtocolInfo , org.fourthline.cling.support.model.ConnectionInfo.Direction)` and `closeConnectionWithPeer(org.fourthline.cling.controlpoint.ControlPoint, org.fourthline.cling.model.meta.Service, org.fourthline.cling.support.model.ConnectionInfo)` methods will block until this method completes handling any failure.

      Parameters:
        `invocation` - The underlying action invocation of the remote connection manager service.
        `operation` - The network message response if there was a response, or `null`.
        `defaultFailureMessage` - A user-friendly error message generated from the invocation exception and response.

Copyright © 2014 4th Line GmbH, Switzerland. All Rights Reserved.