0

我正在使用 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 对之前添加 \" 它会给出一个非常奇怪的结果。那么我怎样才能得到与 (1) 中相同的结果呢?

谢谢!

4

1 回答 1

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);
于 2013-11-08T04:31:28.420 回答