使用 MYNetwork 库浏览服务 (bonjour) 时 txtRecord 为 null
我目前正在使用 MYNetwork 库 Bonjour 类,并且在发现 txt 记录时遇到问题。当一个新的服务出现时,它的txt记录每次都是空的。
在我的服务器端,我以这种方式设置 txt 记录:
self.server = [[MYBonjourRegistration alloc] initWithServiceType: @"_blipecho._tcp." port:9121];
[server setString:@"Cyprian" forTXTKey:@"Name"];
[server start];
然后在浏览器上我发现并记录数据:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqual:@"services"]) {
NSSet *newServices = (NSSet*)[change objectForKey:@"new"];
if(newServices){
MYBonjourService *service;
for (service in newServices){
textView.text = [NSString stringWithFormat:@"%@\nNew user: %@ (%@)", textView.text, service.name, [service txtRecord]];
}
}
}
我得到 txtRecord 的 null 值。
I am currently working with MYNetwork library Bonjour classes and have a problem discovering txt records. When a new service appears it's txt record is null every time.
On my server side I setup txt record this way:
self.server = [[MYBonjourRegistration alloc] initWithServiceType: @"_blipecho._tcp." port:9121];
[server setString:@"Cyprian" forTXTKey:@"Name"];
[server start];
Then on the Browser I discover and log the data:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqual:@"services"]) {
NSSet *newServices = (NSSet*)[change objectForKey:@"new"];
if(newServices){
MYBonjourService *service;
for (service in newServices){
textView.text = [NSString stringWithFormat:@"%@\nNew user: %@ (%@)", textView.text, service.name, [service txtRecord]];
}
}
}
And I get null for the txtRecord.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,得到答案了。
问题是新发现的服务尚未解决,因此没有数据。
必须先解决服务问题。
Ok, got the answer.
The problem was that the newly discovered service is was no yet resolved hence there was no data.
Had to resolve the service first.