本文整理匯總了Java中com.apple.dnssd.TXTRecord類的典型用法代碼示例。如果您正苦於以下問題:Java TXTRecord類的具體用法?Java TXTRecord怎麽用?Java TXTRecord使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TXTRecord類屬於com.apple.dnssd包,在下文中一共展示了TXTRecord類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serviceResolved
import com.apple.dnssd.TXTRecord; //導入依賴的package包/類
@Override
public void serviceResolved(final DNSSDService resolver, final int flags, final int ifIndex,
final String fullname, final String hostname, final int port, final TXTRecord txtRecord) {
if(log.isDebugEnabled()) {
log.debug(String.format("Resolved service with name %s to %s", fullname, hostname));
}
final ActionOperationBatcher autorelease = ActionOperationBatcherFactory.get();
try {
String user = null;
String password = null;
String path = null;
if(log.isDebugEnabled()) {
log.debug(String.format("TXT Record %s", txtRecord));
}
if(txtRecord.contains("u")) {
user = txtRecord.getValueAsString("u");
}
if(txtRecord.contains("p")) {
password = txtRecord.getValueAsString("p");
}
if(txtRecord.contains("path")) {
path = txtRecord.getValueAsString("path");
}
this.add(fullname, hostname, port, user, password, path);
}
finally {
// Note: When the desired results have been returned, the client MUST terminate
// the resolve by calling DNSSDService.stop().
resolver.stop();
autorelease.operate();
}
}
示例2: MDNSResponderServiceInfo
import com.apple.dnssd.TXTRecord; //導入依賴的package包/類
public MDNSResponderServiceInfo(String serviceName, String hostName, int port, TXTRecord txtRecord) {
super();
this.serviceName = serviceName;
this.hostName = hostName;
this.port = port;
this.txtRecord = txtRecord;
}
示例3: register
import com.apple.dnssd.TXTRecord; //導入依賴的package包/類
public void register() throws Exception {
if (m_registered == false) {
final TXTRecord txt = new TXTRecord();
if (m_properties != null) {
for (final String key : m_properties.keySet()) {
txt.set(key, m_properties.get(key));
}
}
DNSSD.register(0, 0, m_serviceName, m_serviceType, null, null, m_port, txt, this);
} else {
System.err.println("WARNING: register() called but the service has already been m_registered!");
}
}