pilotclient icon indicating copy to clipboard operation
pilotclient copied to clipboard

FSD server error hidden by TCP socket error

Open oktal3700 opened this issue 3 years ago • 1 comments

When the server sends a kick packet or error packet and then disconnects the socket, the socket error seems to take priority in the swift GUI, so the server error or kick message gets hidden.

oktal3700 avatar Feb 10 '22 19:02 oktal3700

The issue could possibly be in CFsdClient. If there are too many packets waiting, the method readDataFromSocketMaxLines will return after scheduling itself to be called again in a few milliseconds. The disconnection could occur before the method is called again, and therefore before the error packet has been read.

A solution could be along the following lines:

const QByteArray allBytes = m_socket->peek(m_socket->bytesAvailable());
int index = allBytes.indexOf("\r\n$ER");
if (index < 0) { index = allBytes.indexOf("\r\n$!!"); }
if (index >= 0)
{
    index += 2;
    const int end = allBytes.indexOf("\r\n", index);
    if (end >= 0)
    {
        const QByteArray dataEncoded = allBytes.mid(index, end - index);
        // ...
    }
}

oktal3700 avatar Apr 14 '22 22:04 oktal3700