diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index c1ba825..05f39f0 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -56,21 +56,6 @@ jobs: env: targetName: PolyChatTester steps: - # macos 11.0 默认环境变了,要指定 - - name: prepare env - if: ${{ matrix.os == 'macos-11.0' }} - run: | - softwareupdate --all --install --force - sudo xcode-select --print-path - sudo xcode-select --switch /Library/Developer/CommandLineTools - - name: Install Qt - uses: jurplel/install-qt-action@v3 - with: - version: ${{ matrix.qt_ver }} - cached: 'false' - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - name: Test on macOS run: | cd ./Tester diff --git a/App/db_localdata.h b/App/db_localdata.h index 287c204..88e621f 100644 --- a/App/db_localdata.h +++ b/App/db_localdata.h @@ -7,16 +7,28 @@ #include "uil_chatlist.h" #include "chat.h" -static const qint16 PORT_TCP_FILE = 8848; +/** + * 在此修改配置 + */ +static const qint16 PORT_TCP_FILE = 8848; // TCP 文件发送-接收端口 static const qint16 PORT_CHAT_LIST = 2903; -static const unsigned int TCP_DELAY_MS = 20; +static const unsigned int TCP_DELAY_MS = 20; // TCP 文件发送间隔,防止黏包 +/** + * 群组聊天的端口号范围 + */ static const qint16 PORT_MIN = 1; static const qint16 PORT_MAX = 32767; +/** + * TCP 能够传输的最大文件大小,单位为 Byte + */ static const int FILE_SEND_MAX_BYTES = 1 * 1024 * 1024 * 1024; // bytes +/** + * 本机信息 + */ extern QString localUserName; extern QString localUserGroupNumber; extern QHostAddress localIpAddress ; diff --git a/App/tcpclient.cpp b/App/tcpclient.cpp index 07d34e5..52d936b 100644 --- a/App/tcpclient.cpp +++ b/App/tcpclient.cpp @@ -33,13 +33,13 @@ TcpClient::TcpClient(QWidget *parent, QString fileName, qint64 fileSizeBytes, QH this->tcpSocket = new QTcpSocket(this); /* 如果与主机建立连接 */ - connect(this->tcpSocket, &QTcpSocket::connected, [=](){ + connect(this->tcpSocket, &QTcpSocket::connected, this, [=](){ ui->btnSave->setEnabled(false); appendTextBrowser(Qt::green, "[INFO] Successfully establish a link with the host"); }); /* 如果与主机断开连接 */ - connect(this->tcpSocket, &QTcpSocket::disconnected, [=](){ + connect(this->tcpSocket, &QTcpSocket::disconnected, this, [=](){ ui->btnSave->setEnabled(true); appendTextBrowser(Qt::darkYellow, "[WARNING] Disconnected with the host"); }); @@ -63,7 +63,7 @@ TcpClient::TcpClient(QWidget *parent, QString fileName, qint64 fileSizeBytes, QH connect(ui->btnSave, &QPushButton::clicked, this, &TcpClient::connectTcpServerAndOpenFile); /* 点击 Cancel 按钮 */ - connect(ui->btnCancel, &QPushButton::clicked, [=](){ this->close(); }); + connect(ui->btnCancel, &QPushButton::clicked, this, [=](){ this->close(); }); appendTextBrowser(Qt::blue, "[INFO] Initializing the TCP client done"); appendTextBrowser(Qt::red, "[INFO] Click `Save` to receive the file"); diff --git a/App/tcpserver.cpp b/App/tcpserver.cpp index d0f0adc..5872e86 100644 --- a/App/tcpserver.cpp +++ b/App/tcpserver.cpp @@ -102,7 +102,7 @@ TcpServer::TcpServer(QWidget *parent, QString filePath, QHostAddress ip, qint16 if (len > 0) { appendTextBrowser(Qt::blue, "[INFO] The file header is sent successfully"); - timer->start(TCP_DELAY_MS); + timer->start(TCP_DELAY_MS); // TCP 文件发送间隔,防止黏包 return; } else @@ -198,7 +198,7 @@ void TcpServer::closeEvent(QCloseEvent* event) event->ignore(); } - /* 防止在未发送文件(tcpSocket 未初始化)的情况下关闭窗口出现的奔溃 */ + /* 【注意】这里可以防止在未发送文件(tcpSocket 未初始化)的情况下关闭窗口出现的崩溃 */ if (nullptr != this->tcpSocket) { tcpSocket->disconnectFromHost(); //断开连接