我正在使用JmDNS来模拟Bonjour服务/ AirPlay。
ServiceInfo info = ServiceInfo.create(
"test@AppleTV._airplay._tcp.local",
"test@AppleTV", 46667, "deviceid=00:11:7F:54:DF:0B features=0x2a7f model=AndroidTV2,1 srcvers=130.14");
JmmDNS dns = JmmDNS.Factory.getInstance();
try {
((JmmDNSImpl) dns).inetAddressAdded(new NetworkTopologyEventImpl(
JmDNS.create(InetAddress.getByName("localhost")),
InetAddress.getByName("localhost")));
dns.registerService(info);
Thread.sleep(1000); // If this isn't done the Announcement sometimes
// doesn't go out on the local interface
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
iPhone没有看到我的设备,所以我检查了MBPR上的mDNS日志。结果
(1)工作服务
_airplay._tcp PTR ITV@139._airplay._tcp
ITV@139._airplay._tcp SRV 0 0 46667 localhost.local. ; Replace with unicast FQDN of target host
ITV@139._airplay._tcp TXT "deviceid=00:11:7F:54:DF:0B" "features=0x2a7f" "model=AndroidTV2,1" "srcvers=130.14"
(2)我的非工作服务
_airplay._tcp PTR test@AppleTV._airplay._tcp
test@AppleTV._airplay._tcp SRV 0 0 46667 android-3e71c0c088c7a603.local. ; Replace with unicast FQDN of target host
test@AppleTV._airplay._tcp TXT "eviceid=00:11:7F:54:DF:0B features=0x2a7f model=AndroidTV2,1 srcvers=130.14"
正如你所看到的那样,拳头被切掉了。如果我在每个kv-pair之前添加\“它会给出一个非常奇怪的结果。那么如何得到与(1)中相同的结果呢?
谢谢!
答案 0 :(得分:0)
知道了:
Map<String, String> map = new HashMap<String, String>();
map.put("deviceid", "00:11:7F:54:DF:0B");
map.put("features", "0x2a7f");
map.put("model", "AndroidTV2,1");
map.put("srcvers", "130.14");
ServiceInfo info = ServiceInfo.create(
"tt@AppleTV._airplay._tcp.local",
"tt@AppleTV", 46667,1,1,false, map);