当前位置: 首页>>代码示例>>Java>>正文


Java UpnpService类代码示例

本文整理汇总了Java中org.fourthline.cling.UpnpService的典型用法代码示例。如果您正苦于以下问题:Java UpnpService类的具体用法?Java UpnpService怎么用?Java UpnpService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UpnpService类属于org.fourthline.cling包,在下文中一共展示了UpnpService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: publishService

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
/**
 * Publishes a service for a specified IP address.
 *
 * @param address an address.
 * @param service a service.
 */
public void publishService(@Nonnull InetAddress address, @Nonnull Service service) {
        PortMapping mapping = new PortMapping(
                service.getPort(),
                address.getHostAddress(),
                (service.getType() == ProtocolType.TCP ? PortMapping.Protocol.TCP : PortMapping.Protocol.UDP),
                "Beacon Service (" + service.getDisplayName() + ")"
        );

        // ensure our lease is refreshed every ~30 seconds so we do not end up with zombie leases in our UPnP
        // configuration even when the application or PC crashes
        // FIXME: This causes the lease to expire entirely even while the application is running so we can't quite rely on it at the moment
        // mapping.setLeaseDurationSeconds(new UnsignedIntegerFourBytes(30));

        logger.info("Publishing service %s (using %s on port %d) on %s.", service.getDisplayName(), service.getType(), service.getPort(), address.getAddress());
        UpnpService upnpService = new UpnpServiceImpl(new PortMappingListener(mapping));
        upnpService.getControlPoint().search();
        this.serviceMap.put(service, upnpService);
}
 
开发者ID:dotStart,项目名称:Beacon,代码行数:25,代码来源:ServiceManager.java

示例2: run

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public void run() {
    try {
        final UpnpService upnpService = new UpnpServiceImpl();
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                upnpService.shutdown();
            }
        });
        upnpService.getRegistry().addDevice(createDevice());

    } catch (Exception ex) {
        System.err.println("An exception has occured: " + ex);
        ex.printStackTrace(System.err);
        System.exit(1);
    }
}
 
开发者ID:estevaosaleme,项目名称:PlaySEM_SERenderer,代码行数:18,代码来源:SERendererDevice.java

示例3: run

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public void run() {
    try {
        final ExecutorService executorService = Executors.newSingleThreadExecutor();
        final UpnpService upnpService = new UpnpServiceImpl(serviceConfiguration);
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                upnpService.shutdown();
            }
        });

        // Add the bound local device to the registry
        upnpService.getRegistry().addDevice(createDevice());
    }
    catch (Exception ex) {
        System.err.println("Exception occured: " + ex);
        ex.printStackTrace(System.err);
        System.exit(1);
    }
}
 
开发者ID:camueller,项目名称:SmartApplianceEnabler,代码行数:21,代码来源:SempDiscovery.java

示例4: SendingSubscribe

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public SendingSubscribe(UpnpService upnpService,
                        RemoteGENASubscription subscription,
                        List<NetworkAddress> activeStreamServers) {
    super(
        upnpService,
        new OutgoingSubscribeRequestMessage(
            subscription,
            subscription.getEventCallbackURLs(
                activeStreamServers,
                upnpService.getConfiguration().getNamespace()
            ),
            upnpService.getConfiguration().getEventSubscriptionHeaders(subscription.getService())
        )
    );

    this.subscription = subscription;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:18,代码来源:SendingSubscribe.java

示例5: SendingEvent

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public SendingEvent(UpnpService upnpService, LocalGENASubscription subscription) {
    super(upnpService, null); // Special case, we actually need to send several messages to each callback URL

    // TODO: Ugly design! It is critical (concurrency) that we prepare the event messages here, in the constructor thread!

    subscriptionId = subscription.getSubscriptionId();

    requestMessages = new OutgoingEventRequestMessage[subscription.getCallbackURLs().size()];
    int i = 0;
    for (URL url : subscription.getCallbackURLs()) {
        requestMessages[i] = new OutgoingEventRequestMessage(subscription, url);
        getUpnpService().getConfiguration().getGenaEventProcessor().writeBody(requestMessages[i]);
        i++;
    }

    currentSequence = subscription.getCurrentSequence();

    // Always increment sequence now, as (its value) has already been set on the headers and the
    // next event will use the incremented value
    subscription.incrementSequence();
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:22,代码来源:SendingEvent.java

示例6: makeUpnpService

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
private UpnpService makeUpnpService() {
    return new UpnpServiceImpl(createConfiguration()) {
        @Override protected Router createRouter(ProtocolFactory protocolFactory, Registry registry) {
            return new AndroidRouter(getConfiguration(), protocolFactory,  UpnpServiceService.this);
        }
        @Override public synchronized void shutdown() {
            // First have to remove the receiver, so Android won't complain about it leaking
            // when the main UI thread exits.
            ((AndroidRouter)getRouter()).unregisterBroadcastReceiver();

            // Now we can concurrently run the Cling shutdown code, without occupying the
            // Android main UI thread. This will complete probably after the main UI thread
            // is done.
            super.shutdown(true);
        }
    };
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:18,代码来源:UpnpServiceService.java

示例7: run

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public void run() {
	try {

		final UpnpService upnpService = new UpnpServiceImpl();

		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				upnpService.shutdown();
			}
		});

		// Add the bound local device to the registry
		upnpService.getRegistry().addDevice(createDevice());

	} catch (final Exception ex) {
		System.err.println("Exception occured: " + ex);
		ex.printStackTrace(System.err);
		System.exit(1);
	}
}
 
开发者ID:nhrdl,项目名称:gnucashMobile,代码行数:22,代码来源:Main.java

示例8: getUpnpService

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
/**
 * Returns the cling UpnpService.
 *
 * @return the cling UpnpService
 */
public UpnpService getUpnpService() {
    if (!isInitialized()) {
        return null;
    }
    return androidUpnpService.get();
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:12,代码来源:UpnpClient.java

示例9: unpublishService

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
/**
 * Un-Publishes a service.
 *
 * @param service a service.
 */
public void unpublishService(@Nonnull Service service) {
        UpnpService upnpService = this.serviceMap.get(service);

        if (upnpService == null) {
                throw new NoSuchElementException("No such service: " + service);
        }

        logger.info("Un-publishing service %s (using %s on port %d).", service.getDisplayName(), service.getType(), service.getPort());
        upnpService.shutdown();
        this.serviceMap.remove(service);
}
 
开发者ID:dotStart,项目名称:Beacon,代码行数:17,代码来源:ServiceManager.java

示例10: SendingUnsubscribe

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public SendingUnsubscribe(UpnpService upnpService, RemoteGENASubscription subscription) {
    super(
        upnpService,
        new OutgoingUnsubscribeRequestMessage(
            subscription,
            upnpService.getConfiguration().getEventSubscriptionHeaders(subscription.getService())
        )
    );
    this.subscription = subscription;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:11,代码来源:SendingUnsubscribe.java

示例11: SendingRenewal

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public SendingRenewal(UpnpService upnpService, RemoteGENASubscription subscription) {
    super(
        upnpService,
        new OutgoingRenewalRequestMessage(
            subscription,
            upnpService.getConfiguration().getEventSubscriptionHeaders(subscription.getService())
        )
    );
    this.subscription = subscription;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:11,代码来源:SendingRenewal.java

示例12: SendingSearch

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
/**
 * @param mxSeconds The time in seconds a host should wait before responding.
 */
public SendingSearch(UpnpService upnpService, UpnpHeader searchTarget, int mxSeconds) {
    super(upnpService);

    if (!UpnpHeader.Type.ST.isValidHeaderType(searchTarget.getClass())) {
        throw new IllegalArgumentException(
                "Given search target instance is not a valid header class for type ST: " + searchTarget.getClass()
        );
    }
    this.searchTarget = searchTarget;
    this.mxSeconds = mxSeconds;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:15,代码来源:SendingSearch.java

示例13: RegistryImpl

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
/**
 * Starts background maintenance immediately.
 */
@Inject
public RegistryImpl(UpnpService upnpService) {
    log.fine("Creating Registry: " + getClass().getName());

    this.upnpService = upnpService;

    log.fine("Starting registry background maintenance...");
    registryMaintainer = createRegistryMaintainer();
    if (registryMaintainer != null) {
        getConfiguration().getRegistryMaintainerExecutor().execute(registryMaintainer);
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:16,代码来源:RegistryImpl.java

示例14: getUpnpService

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
/**
 * Returns the cling UpnpService.
 * 
 * @return the cling UpnpService
 */
public UpnpService getUpnpService() {
	if (!isInitialized()) {
		return null;
	}
	return androidUpnpService.get();
}
 
开发者ID:msafin,项目名称:wmc,代码行数:12,代码来源:UpnpClient.java

示例15: getUpnpService

import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public UpnpService getUpnpService() {
    return upnpService;
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:4,代码来源:UPnPService.java


注:本文中的org.fourthline.cling.UpnpService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。