本文整理汇总了Java中javax.jmdns.impl.DNSQuestion.iAmTheOnlyOne方法的典型用法代码示例。如果您正苦于以下问题:Java DNSQuestion.iAmTheOnlyOne方法的具体用法?Java DNSQuestion.iAmTheOnlyOne怎么用?Java DNSQuestion.iAmTheOnlyOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jmdns.impl.DNSQuestion
的用法示例。
在下文中一共展示了DNSQuestion.iAmTheOnlyOne方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javax.jmdns.impl.DNSQuestion; //导入方法依赖的package包/类
@Override
public void start(Timer timer) {
// According to draft-cheshire-dnsext-multicastdns.txt chapter "7 Responding":
// We respond immediately if we know for sure, that we are the only one who can respond to the query.
// In all other cases, we respond within 20-120 ms.
//
// According to draft-cheshire-dnsext-multicastdns.txt chapter "6.2 Multi-Packet Known Answer Suppression":
// We respond after 20-120 ms if the query is truncated.
boolean iAmTheOnlyOne = true;
for (DNSQuestion question : _in.getQuestions()) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest(this.getName() + "start() question=" + question);
}
iAmTheOnlyOne = question.iAmTheOnlyOne(this.getDns());
if (!iAmTheOnlyOne) {
break;
}
}
int delay = (iAmTheOnlyOne && !_in.isTruncated()) ? 0 : DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + JmDNSImpl.getRandom().nextInt(DNSConstants.RESPONSE_MAX_WAIT_INTERVAL - DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + 1) - _in.elapseSinceArrival();
if (delay < 0) {
delay = 0;
}
if (logger.isLoggable(Level.FINEST)) {
logger.finest(this.getName() + "start() Responder chosen delay=" + delay);
}
if (!this.getDns().isCanceling() && !this.getDns().isCanceled()) {
timer.schedule(this, delay);
}
}
示例2: start
import javax.jmdns.impl.DNSQuestion; //导入方法依赖的package包/类
@Override
public void start(Timer timer)
{
// According to draft-cheshire-dnsext-multicastdns.txt chapter "7 Responding":
// We respond immediately if we know for sure, that we are the only one who can respond to the query.
// In all other cases, we respond within 20-120 ms.
//
// According to draft-cheshire-dnsext-multicastdns.txt chapter "6.2 Multi-Packet Known Answer Suppression":
// We respond after 20-120 ms if the query is truncated.
boolean iAmTheOnlyOne = true;
for (DNSQuestion question : _in.getQuestions())
{
if (logger.isLoggable(Level.FINEST))
{
logger.finest(this.getName() + "start() question=" + question);
}
iAmTheOnlyOne = question.iAmTheOnlyOne(this.getDns());
if (!iAmTheOnlyOne)
{
break;
}
}
int delay = (iAmTheOnlyOne && !_in.isTruncated()) ? 0 : DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + JmDNSImpl.getRandom().nextInt(DNSConstants.RESPONSE_MAX_WAIT_INTERVAL - DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + 1) - _in.elapseSinceArrival();
if (delay < 0)
{
delay = 0;
}
if (logger.isLoggable(Level.FINEST))
{
logger.finest(this.getName() + "start() Responder chosen delay=" + delay);
}
if (!this.getDns().isCanceling() && !this.getDns().isCanceled())
{
timer.schedule(this, delay);
}
}