Possible keys for AlternateIdentities in Peerfinder

寵の児 提交于 2019-12-19 09:01:04

问题


I'm trying to get a hold on specific devices by using the PeerFinder class in Windows 8 / Windows Phone 8.

Following the example as shown in the Build presentation: http://channel9.msdn.com/Events/Build/2012/3-047

I got the paired bluetooth devices by using these lines:

PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = "";

var devices = await PeerFinder.FindAllPeersAsync();

But now I would like to get a list of devices that are connected via bluetooth or maybe even other devices by using a different key in the:

PeerFinder.AlternateIdentities[KEY] = "";

line of code. The MSDN documentation isn't helpful in this case.


回答1:


Windows Phone 8 bluetooth APIs can really only be used in a few ways (and those are driven by AlternateIdentities):

1) app-to-device / WP8-to-device. This will only work for paired devices. WP8 bluetooth APIs cannot communicate with bluetooth devices that aren't paired to it. As you've discovered AlternateIdentities["Bluetooth:Paired"]="" is the right thing to use for this usecase.

2) app-to-app / WP8-to-WP8. This allows WP8 apps to communicate with the same app on different phones. You specifically need to avoid setting AlternateIdentities for app-to-app to work.

3) app-to-app / WP8-to-Win8. Using specific AlternativeIdentities on both ends it's also possible to get app-to-app to work for WP8-to-Win8. You'll need to set PeerFinder.AlternateIdentities["WindowsPhone"] on Win8 to the WP8 app GUID, and you'll need to add PeerFinder.AlternateIdentities.Add("Windows",GUID) on WP8 to the Win8 app GUID.

There are other AlternateIdentities formats we haven't shared publicly since they don't apply to 3rd party developers. When thinking about usecases for Bluetooth on WP8 focus on app-to-app and app-to-device.



来源:https://stackoverflow.com/questions/13490318/possible-keys-for-alternateidentities-in-peerfinder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!