Java Code Examples for javax.jmdns.ServiceInfo#getPropertyString()
The following examples show how to use
javax.jmdns.ServiceInfo#getPropertyString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TradfriDiscoveryParticipant.java From smarthome with Eclipse Public License 2.0 | 6 votes |
@Override public DiscoveryResult createResult(ServiceInfo service) { ThingUID thingUID = getThingUID(service); if (thingUID != null) { if (service.getHostAddresses() != null && service.getHostAddresses().length > 0 && !service.getHostAddresses()[0].isEmpty()) { logger.debug("Discovered Tradfri gateway: {}", service); Map<String, Object> properties = new HashMap<>(4); properties.put(PROPERTY_VENDOR, "IKEA of Sweden"); properties.put(GATEWAY_CONFIG_HOST, service.getHostAddresses()[0]); properties.put(GATEWAY_CONFIG_PORT, service.getPort()); properties.put(PROPERTY_SERIAL_NUMBER, service.getName()); String fwVersion = service.getPropertyString("version"); if (fwVersion != null) { properties.put(PROPERTY_FIRMWARE_VERSION, fwVersion); } return DiscoveryResultBuilder.create(thingUID).withProperties(properties).withLabel("TRÅDFRI Gateway") .withRepresentationProperty(GATEWAY_CONFIG_HOST).build(); } else { logger.warn("Discovered Tradfri gateway doesn't have an IP address: {}", service); } } return null; }
Example 2
Source File: ChromeCast.java From chromecast-java-api-v2 with Apache License 2.0 | 5 votes |
ChromeCast(JmDNS mDNS, String name) { this.name = name; ServiceInfo serviceInfo = mDNS.getServiceInfo(SERVICE_TYPE, name); this.address = serviceInfo.getInet4Addresses()[0].getHostAddress(); this.port = serviceInfo.getPort(); this.appsURL = serviceInfo.getURLs().length == 0 ? null : serviceInfo.getURLs()[0]; this.application = serviceInfo.getApplication(); this.title = serviceInfo.getPropertyString("fn"); this.appTitle = serviceInfo.getPropertyString("rs"); this.model = serviceInfo.getPropertyString("md"); }
Example 3
Source File: BonjourPeer.java From fdroidclient with GNU General Public License v3.0 | 5 votes |
/** * Return a instance if the {@link ServiceInfo} is fully resolved and does * not represent this device, but something else on the network. */ @Nullable public static BonjourPeer getInstance(ServiceInfo serviceInfo) { String type = serviceInfo.getPropertyString(TYPE); String fingerprint = serviceInfo.getPropertyString(FINGERPRINT); if (type == null || !type.startsWith("fdroidrepo") || TextUtils.equals(FDroidApp.repo.fingerprint, fingerprint)) { return null; } return new BonjourPeer(serviceInfo); }