适用于多种设备的WiFi Direct [英] WiFi Direct for multiple devices
问题描述
我正在尝试通过
http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html
这已说明了如何管理2台设备之间的连接.经过关于stackoverflow的一些帖子后,此帖子- WiFi Direct(Android 4.0)和多个(3个以上)设备解释了如何以A-> B和C-> B的方式连接3台设备,我将B视为组所有者.我想知道是否可以通过某种方式同时传输B-> A和B-> C的文件.
This has explained how to manage connections between 2 devices. After going through some posts on stackoverflow, this post - WiFi Direct (Android 4.0) with multiple (3+) devices has explained how to connect 3 devices in a manner where A->B and C->B, where I've considered B as my Group Owner. I wanted to know if there is any way in which I can transfer a file in a manner where B->A and B->C simultaneously.
感谢您的所有帮助!:)
Thanks for all your help! :)
推荐答案
由于B是组所有者(GO),A和C是客户,因此B可以通过 WifiP2pManager.requestGroupInfo的回调函数获取客户的地址.().
Since B is the group owner(GO) and A and C are clients, B can get clients' address by the callback function of WifiP2pManager.requestGroupInfo() .
像这样连接后请求群组信息.
Request group info after connected like this.
mWifiP2pManager.requestGroupInfo(mChannel,new WifiP2pManager.GroupInfoListener() {
@Override
public void onGroupInfoAvailable(WifiP2pGroup wifiP2pGroup) {
Collection<WifiP2pDevice> peerList = wifiP2pGroup.getClientList();
ArrayList<WifiP2pDevice> list = new ArrayList<WifiP2pDevice>(peerList);
String host;
for (int i = 1; i < list.size(); i++) {
host = list.get(i).deviceAddress;
/** transferFile here **/
}
}
});
这篇关于适用于多种设备的WiFi Direct的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!