disconnect method
断开连接
如果设备正处于连接状态,需要等待设备退出连接后再调用
bool ret = await AppP2PApi().clientDisconnect(clientPtr);
调用clientDisconnect如果返回true,则说明设备曾经连接成功,
需要等待设备回调disconnect才能确保设备已经完全断开连接
需要调用await _waitDisconnected()来确认设备已经完全断开
@return true 连接已断开 false 断开失败
Implementation
Future<bool> disconnect() async {
int clientPtr = await getClientPtr();
AppP2PApi().clientConnectBreak(clientPtr);
bool ret = await _waitConnected();
ret = await AppP2PApi().clientDisconnect(clientPtr);
if (ret) {
ret = await _waitDisconnected();
AppP2PApi().removeConnectListener(clientPtr);
}
return ret;
}