From 024e842710d9f85a575d4c87aaebfea4d1225dd5 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Thu, 20 Jun 2019 23:30:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A4=9A=E5=8F=B0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=B2=A1=E5=BF=85=E8=A6=81=E5=88=86=E9=85=8D=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QtScrcpy/devicemanage/devicemanage.cpp | 9 +++++++-- TODO.md | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/QtScrcpy/devicemanage/devicemanage.cpp b/QtScrcpy/devicemanage/devicemanage.cpp index de2d2fa..d197b64 100644 --- a/QtScrcpy/devicemanage/devicemanage.cpp +++ b/QtScrcpy/devicemanage/devicemanage.cpp @@ -27,6 +27,8 @@ bool DeviceManage::connectDevice(Device::DeviceParams params) qInfo("over the maximum number of connections"); return false; } + /* + // 没有必要分配端口,都用27183即可,连接建立以后server会释放监听的 quint16 port = 0; if (params.useReverse) { port = getFreePort(); @@ -34,9 +36,11 @@ bool DeviceManage::connectDevice(Device::DeviceParams params) qInfo("no port available, automatically switch to forward"); params.useReverse = false; } else { + params.localPort = port; qInfo("free port %d", port); } } + */ Device *device = new Device(params); connect(device, &Device::deviceDisconnect, this, &DeviceManage::onDeviceDisconnect); m_devices[params.serial] = device; @@ -65,10 +69,10 @@ void DeviceManage::onDeviceDisconnect(QString serial) quint16 DeviceManage::getFreePort() { - quint16 port = m_localPortStart; - QMapIterator> i(m_devices); + quint16 port = m_localPortStart; while (port < m_localPortStart + DM_MAX_DEVICES_NUM) { bool used = false; + QMapIterator> i(m_devices); while (i.hasNext()) { i.next(); auto device = i.value(); @@ -82,6 +86,7 @@ quint16 DeviceManage::getFreePort() if (!used) { return port; } + port++; } return 0; } diff --git a/TODO.md b/TODO.md index a39d676..f1c3418 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,12 @@ 2. [֡Ϊ̬ãǾ̬](https://github.com/Genymobile/scrcpy/commit/ebccb9f6cc111e8acfbe10d656cac5c1f1b744a0) 3. [߳ͳ֡](https://github.com/Genymobile/scrcpy/commit/e2a272bf99ecf48fcb050177113f903b3fb323c4) 4. uiṩshow touch -5. Ⱥ +5. קļְװļƣʾ· +6. ֹͣз +7. ק +8. /ֹͣΪ豸/Ͽ豸 +9. öΪö +10. jpg # mark