use of javax.jmdns.ServiceInfo in project EngineDriver by JMRI.
the class JmmDNSImpl method listBySubtype.
/*
* (non-Javadoc)
* @see javax.jmdns.JmmDNS#listBySubtype(java.lang.String, long)
*/
@Override
public Map<String, ServiceInfo[]> listBySubtype(final String type, final long timeout) {
Map<String, List<ServiceInfo>> map = new HashMap<String, List<ServiceInfo>>(5);
for (ServiceInfo info : this.list(type, timeout)) {
String subtype = info.getSubtype();
if (!map.containsKey(subtype)) {
map.put(subtype, new ArrayList<ServiceInfo>(10));
}
map.get(subtype).add(info);
}
Map<String, ServiceInfo[]> result = new HashMap<String, ServiceInfo[]>(map.size());
for (String subtype : map.keySet()) {
List<ServiceInfo> infoForSubType = map.get(subtype);
result.put(subtype, infoForSubType.toArray(new ServiceInfo[infoForSubType.size()]));
}
return result;
}
use of javax.jmdns.ServiceInfo in project EngineDriver by JMRI.
the class ServiceResolver method addAnswers.
/*
* (non-Javadoc)
* @see javax.jmdns.impl.tasks.Resolver#addAnswers(javax.jmdns.impl.DNSOutgoing)
*/
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
DNSOutgoing newOut = out;
long now = System.currentTimeMillis();
for (ServiceInfo info : this.getDns().getServices().values()) {
newOut = this.addAnswer(newOut, new DNSRecord.Pointer(info.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getQualifiedName()), now);
// newOut = this.addAnswer(newOut, new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(),
// this.getDns().getLocalHost().getName()), now);
}
return newOut;
}
use of javax.jmdns.ServiceInfo in project smarthome by eclipse.
the class MDNSDiscoveryService method scan.
private void scan() {
for (MDNSDiscoveryParticipant participant : participants) {
ServiceInfo[] services = mdnsClient.list(participant.getServiceType());
logger.debug("{} services found for {}", services.length, participant.getServiceType());
for (ServiceInfo service : services) {
DiscoveryResult result = participant.createResult(service);
if (result != null) {
thingDiscovered(result);
}
}
}
for (org.eclipse.smarthome.io.transport.mdns.discovery.MDNSDiscoveryParticipant participant : oldParticipants) {
ServiceInfo[] services = mdnsClient.list(participant.getServiceType());
logger.debug("{} services found for {}", services.length, participant.getServiceType());
for (ServiceInfo service : services) {
DiscoveryResult result = participant.createResult(service);
if (result != null) {
thingDiscovered(result);
}
}
}
}
use of javax.jmdns.ServiceInfo in project smarthome by eclipse.
the class MDNSClientImpl method registerService.
@Override
public void registerService(ServiceDescription description) throws IOException {
for (JmDNS instance : jmdnsInstances) {
logger.debug("Registering new service {} at {}:{} ({})", description.serviceType, instance.getInetAddress().getHostAddress(), description.servicePort, instance.getName());
// Create one ServiceInfo object for each JmDNS instance
ServiceInfo serviceInfo = ServiceInfo.create(description.serviceType, description.serviceName, description.servicePort, 0, 0, description.serviceProperties);
instance.registerService(serviceInfo);
}
}
use of javax.jmdns.ServiceInfo in project JAirPort by froks.
the class JmDNSImpl method listBySubtype.
/**
* {@inheritDoc}
*/
@Override
public Map<String, ServiceInfo[]> listBySubtype(String type, long timeout) {
Map<String, List<ServiceInfo>> map = new HashMap<String, List<ServiceInfo>>(5);
for (ServiceInfo info : this.list(type, timeout)) {
String subtype = info.getSubtype().toLowerCase();
if (!map.containsKey(subtype)) {
map.put(subtype, new ArrayList<ServiceInfo>(10));
}
map.get(subtype).add(info);
}
Map<String, ServiceInfo[]> result = new HashMap<String, ServiceInfo[]>(map.size());
for (String subtype : map.keySet()) {
List<ServiceInfo> infoForSubType = map.get(subtype);
result.put(subtype, infoForSubType.toArray(new ServiceInfo[infoForSubType.size()]));
}
return result;
}
Aggregations