我有以下代码应该在打包的chrome应用程序的后台脚本中获取多播设备列表
const onDevices = (devices) => {
console.log(devices);
}
const serviceType = '_http._tcp';
chrome.app.window.create('window.html', {
outerBounds: {
width: 400,
height: 500
}
});
chrome.mdns.onServiceList.addListener(onDevices, {serviceType});
chrome.mdns.forceDiscovery(() => {
console.log('start');
})
但是当我运行console.log(devices)
时,我总是以一个空列表结尾。无论我将serviceType
设置为什么,都会发生这种情况。
如果重要的话,我正在使用清单版本2。
我知道网络上有多播设备,所以有什么主意吗?
谢谢!