Skip to content

Commit

Permalink
优化 MoacOS CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nekosilverfox committed Oct 18, 2023
1 parent 6f1732e commit 41bfb7a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions App/db_localdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
6 changes: 3 additions & 3 deletions App/tcpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions App/tcpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -198,7 +198,7 @@ void TcpServer::closeEvent(QCloseEvent* event)
event->ignore();
}

/* 防止在未发送文件(tcpSocket 未初始化)的情况下关闭窗口出现的奔溃 */
/* 【注意】这里可以防止在未发送文件(tcpSocket 未初始化)的情况下关闭窗口出现的崩溃 */
if (nullptr != this->tcpSocket)
{
tcpSocket->disconnectFromHost(); //断开连接
Expand Down

0 comments on commit 41bfb7a

Please sign in to comment.