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