private void fillCommandServiceInfo(String hostName, int port, TXTRecord txtRecord) { info.setId(new Identifier(domainId, serviceName)); info.setAddress(new SocketAddress(hostName, port)); byte[] nameBytes = txtRecord.getValue(DNSSDDiscoveryServiceAdapter.NAME); if (nameBytes != null) info.setName(Util.decode(nameBytes)); restoreMetadata(info, txtRecord, ICommandServiceInfo.VERSION); restoreMetadata(info, txtRecord, ICommandServiceInfo.CLIENT_NAME); restoreMetadata(info, txtRecord, ICommandServiceInfo.CLIENT_SYMBOLIC_NAME); restoreMetadata(info, txtRecord, ICommandServiceInfo.CLIENT_VERSION); restoreMetadata(info, txtRecord, ICommandServiceInfo.CLIENT_BUILD_ID); }
private static void restoreMetadata( SocketCommandServiceInfo info, TXTRecord txtRecord, String key) { byte[] bytes = txtRecord.getValue(key); info.setMetadata(key, bytes == null ? null : Util.decode(bytes)); }