open method
Opens a new stream to the remote peer, ensuring that the connection is established and the stream is open.
Implementation
Future<AdbStream> open(String destination) async {
if (!_adbConnected) {
throw Exception('Not connected to ADB');
}
int localId = openStreams.length + 1;
AdbStream stream = AdbStream(localId, this);
openStreams[localId] = stream;
sendMessage(AdbProtocol.generateOpen(localId, destination), flush: true);
if (await stream.onWriteReady.first.timeout(const Duration(seconds: 10), onTimeout: () => false)) {
return stream;
} else {
throw Exception('Stream open failed or refused by remote peer');
}
}