我有一个 Wifi Direct Android 应用程序,它将在两部手机上运行。
当phone1连接到 时phone2,我想phone1充当 aclient并phone2充当server。
我使用了这段代码:
if (info.groupFormed && info.isGroupOwner) {
// start the server thread
} else if (info.groupFormed) {
// start the client thread
}
但问题是,有时phone1它启动了连接,我希望它充当客户端,有时它充当客户端,GroupOwner并且服务器线程在客户端电话上启动。
我想确保phone2始终充当 aGroupOwner和 a server。