Skip to content

Commit 8eff49a

Browse files
Fixed small bug with settings button being stuck in disabled after an unexpected disconnect, as well as added a new feature for the server to check if the connection is comming froms someone using the app instead of bots trying to ping it and take up space on the server.
1 parent 41c596e commit 8eff49a

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

mainwindow.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,10 @@ MainWindow::MainWindow(QWidget *parent)
357357
});
358358

359359
connect(socket, &QTcpSocket::readyRead, this, [this]() {
360-
361-
// Drain buffered data. This prevents "tiny files" from stalling when
362-
// file bytes + next JSON line arrive in the same TCP packet.
363360
while (true)
364361
{
365-
// =========================
366-
// MODE 0: read client ID int
367-
// =========================
368362
if (mode == 0)
369363
{
370-
// Only read exactly sizeof(int). Do NOT readAll() or you can
371-
// accidentally consume buffered JSON that arrived right after the id.
372364
if (socket->bytesAvailable() < (qint64)sizeof(int))
373365
return;
374366

@@ -382,23 +374,21 @@ MainWindow::MainWindow(QWidget *parent)
382374

383375
ui->ClientID->setText("Client ID: " + QString::number(id));
384376
myId = id;
377+
378+
socket->write("DirectFilePushClient");
379+
385380
mode = 1;
386381

387-
// Keep looping in case JSON is already buffered
388382
continue;
389383
}
390384

391-
// =========================
392-
// MODE 1: newline-delimited JSON control messages
393-
// =========================
394385
if (mode == 1)
395386
{
396-
// Only parse when we have a full line ending in '\n'
397387
if (!socket->canReadLine())
398388
return;
399389

400390
QByteArray line = socket->readLine();
401-
line = line.trimmed(); // remove '\n' and possible '\r'
391+
line = line.trimmed();
402392

403393
if (line.isEmpty())
404394
continue;
@@ -1189,6 +1179,7 @@ MainWindow::MainWindow(QWidget *parent)
11891179
ui->sendButton->setEnabled(true);
11901180
ui->pairButton->setEnabled(true);
11911181
ui->MessageInput->setEnabled(true);
1182+
ui->settingsButton->setEnabled(true);
11921183
ui->ActivateEncryption->setEnabled(false);
11931184
ui->ActivateEncryption->setChecked(false);
11941185

0 commit comments

Comments
 (0)