Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.teleal.cling.support.igd
Class PortMappingListener

    java.lang.Object
      org.teleal.cling.registry.DefaultRegistryListener
          org.teleal.cling.support.igd.PortMappingListener

All Implemented Interfaces:
  org.teleal.cling.registry.RegistryListener

    public class PortMappingListener

extends org.teleal.cling.registry.DefaultRegistryListener

Maintains UPnP port mappings on an InternetGatewayDevice automatically.

This listener will wait for discovered devices which support either `WANIPConnection` or the `WANPPPConnection` service. As soon as any such service is discovered, the desired port mapping will be created. When the UPnP service is shutting down, all previously established port mappings with all services will be deleted.

The following listener maps external WAN TCP port 8123 to internal host 10.0.0.2:

    upnpService.getRegistry().addListener(
    newPortMappingListener(newPortMapping(8123, "10.0.0.2",PortMapping.Protocol.TCP))
     );

If all you need from the Cling UPnP stack is NAT port mapping, use the following idiom:

    UpnpService upnpService = new UpnpServiceImpl(
         new PortMappingListener(new PortMapping(8123, "10.0.0.2", PortMapping.Protocol.TCP))
     );
     <p/>
     upnpService.getControlPoint().search(new STAllHeader()); // Search for all devices
     <p/>
     upnpService.shutdown(); // When you no longer need the port mapping

Author:
  Christian Bauer

Field Summary
`protected java.util.Map<org.teleal.cling.model.meta.Service,java.util.List<PortMapping>>` | `activePortMappings`
`static org.teleal.cling.model.types.DeviceType` | `CONNECTION_DEVICE_TYPE`
`static org.teleal.cling.model.types.DeviceType` | `IGD_DEVICE_TYPE`
`static org.teleal.cling.model.types.ServiceType` | `IP_SERVICE_TYPE`
`protected PortMapping[]` | `portMappings`
`static org.teleal.cling.model.types.ServiceType` | `PPP_SERVICE_TYPE`

Constructor Summary
`PortMappingListener(PortMapping portMapping)`
`PortMappingListener(PortMapping[] portMappings)`

Method Summary
`void` | `beforeShutdown(org.teleal.cling.registry.Registry registry)`
`void` | `deviceAdded(org.teleal.cling.registry.Registry registry, org.teleal.cling.model.meta.Device device)`
`void` | `deviceRemoved(org.teleal.cling.registry.Registry registry, org.teleal.cling.model.meta.Device device)`
`protected org.teleal.cling.model.meta.Service` | `discoverConnectionService(org.teleal.cling.model.meta.Device device)`
`protected void` | `handleFailureMessage(java.lang.String s)`

Methods inherited from class org.teleal.cling.registry.DefaultRegistryListener
`afterShutdown, localDeviceAdded, localDeviceRemoved, remoteDeviceAdded, remoteDeviceDiscoveryFailed, remoteDeviceDiscoveryStarted, remoteDeviceRemoved, remoteDeviceUpdated`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### IGD_DEVICE_TYPE

    public static final org.teleal.cling.model.types.DeviceType IGD_DEVICE_TYPE

### CONNECTION_DEVICE_TYPE

    public static final org.teleal.cling.model.types.DeviceType CONNECTION_DEVICE_TYPE

### IP_SERVICE_TYPE

    public static final org.teleal.cling.model.types.ServiceType IP_SERVICE_TYPE

### PPP_SERVICE_TYPE

    public static final org.teleal.cling.model.types.ServiceType PPP_SERVICE_TYPE

### portMappings

    protected PortMapping[] portMappings

### activePortMappings

    protected java.util.Map<org.teleal.cling.model.meta.Service,java.util.List<PortMapping>> activePortMappings

Constructor Detail

### PortMappingListener

    public PortMappingListener(PortMapping portMapping)

### PortMappingListener

    public PortMappingListener(PortMapping[] portMappings)

Method Detail

### deviceAdded

    public void deviceAdded(org.teleal.cling.registry.Registry registry,
                            org.teleal.cling.model.meta.Device device)

  Overrides:
    `deviceAdded` in class `org.teleal.cling.registry.DefaultRegistryListener`

### deviceRemoved

    public void deviceRemoved(org.teleal.cling.registry.Registry registry,
                              org.teleal.cling.model.meta.Device device)

  Overrides:
    `deviceRemoved` in class `org.teleal.cling.registry.DefaultRegistryListener`

### beforeShutdown

    public void beforeShutdown(org.teleal.cling.registry.Registry registry)

  Specified by:
    `beforeShutdown` in interface `org.teleal.cling.registry.RegistryListener`
  Overrides:
    `beforeShutdown` in class `org.teleal.cling.registry.DefaultRegistryListener`

### discoverConnectionService

    protected org.teleal.cling.model.meta.Service discoverConnectionService(org.teleal.cling.model.meta.Device device)

### handleFailureMessage

    protected void handleFailureMessage(java.lang.String s)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Teleal GmbH, Switzerland. All Rights Reserved.