View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.connectionmanager.callback;
17  
18  import org.fourthline.cling.controlpoint.ActionCallback;
19  import org.fourthline.cling.controlpoint.ControlPoint;
20  import org.fourthline.cling.model.ServiceReference;
21  import org.fourthline.cling.model.action.ActionInvocation;
22  import org.fourthline.cling.model.meta.Service;
23  import org.fourthline.cling.support.model.ConnectionInfo;
24  import org.fourthline.cling.support.model.ProtocolInfo;
25  
26  /**
27   * @author Alessio Gaeta
28   * @author Christian Bauer
29   */
30  public abstract class PrepareForConnection extends ActionCallback {
31  
32      public PrepareForConnection(Service service,
33                                  ProtocolInfo remoteProtocolInfo, ServiceReference peerConnectionManager,
34                                  int peerConnectionID, ConnectionInfo.Direction direction) {
35          this(service, null, remoteProtocolInfo, peerConnectionManager, peerConnectionID, direction);
36      }
37  
38      public PrepareForConnection(Service service, ControlPoint controlPoint,
39                                  ProtocolInfo remoteProtocolInfo, ServiceReference peerConnectionManager,
40                                  int peerConnectionID, ConnectionInfo.Direction direction) {
41          super(new ActionInvocation(service.getAction("PrepareForConnection")), controlPoint);
42  
43          getActionInvocation().setInput("RemoteProtocolInfo", remoteProtocolInfo.toString());
44          getActionInvocation().setInput("PeerConnectionManager", peerConnectionManager.toString());
45          getActionInvocation().setInput("PeerConnectionID", peerConnectionID);
46          getActionInvocation().setInput("Direction", direction.toString());
47      }
48  
49      @Override
50      public void success(ActionInvocation invocation) {
51          received(
52                  invocation,
53                  (Integer)invocation.getOutput("ConnectionID").getValue(),
54                  (Integer)invocation.getOutput("RcsID").getValue(),
55                  (Integer)invocation.getOutput("AVTransportID").getValue()
56          );
57      }
58  
59      public abstract void received(ActionInvocation invocation, int connectionID, int rcsID, int avTransportID);
60  
61  }