本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
};
}
示例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);
}
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例15: getUpnpService
import org.fourthline.cling.UpnpService; //导入依赖的package包/类
public UpnpService getUpnpService() {
return upnpService;
}