fix: restore client protocol downgrade message
This commit is contained in:
parent
bcd3a658fc
commit
fc44b0bb18
1 changed files with 20 additions and 4 deletions
|
|
@ -15,6 +15,7 @@
|
|||
#include "common/NetworkProtocol.h"
|
||||
#include "common/Settings.h"
|
||||
#include "deskflow/Clipboard.h"
|
||||
#include "deskflow/DeskflowException.h"
|
||||
#include "deskflow/IPlatformScreen.h"
|
||||
#include "deskflow/PacketStreamFilter.h"
|
||||
#include "deskflow/ProtocolTypes.h"
|
||||
|
|
@ -632,14 +633,29 @@ void Client::handleHello()
|
|||
return;
|
||||
}
|
||||
|
||||
LOG_DEBUG(
|
||||
"saying hello back with version %s %d.%d", protocolName.c_str(), kProtocolMajorVersion, kProtocolMinorVersion
|
||||
);
|
||||
if (serverMajor != kProtocolMajorVersion) {
|
||||
LOG_WARN("server protocol version not compatible: %d.%d", serverMajor, serverMinor);
|
||||
sendConnectionFailedEvent(IncompatibleClientException(serverMajor, serverMinor).what());
|
||||
cleanupTimer();
|
||||
cleanupConnection();
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t helloBackMinor = kProtocolMinorVersion;
|
||||
if (serverMinor < kProtocolMinorVersion) {
|
||||
helloBackMinor = serverMinor;
|
||||
LOG_INFO(
|
||||
"downgrading client protocol version from %d.%d to %d.%d", //
|
||||
kProtocolMajorVersion, kProtocolMinorVersion, kProtocolMajorVersion, helloBackMinor
|
||||
);
|
||||
}
|
||||
|
||||
LOG_DEBUG("saying hello back with version %s %d.%d", protocolName.c_str(), kProtocolMajorVersion, helloBackMinor);
|
||||
|
||||
// dynamically build write format for hello back since `ProtocolUtil::writef`
|
||||
// doesn't support formatting fixed length strings yet.
|
||||
std::string helloBackMessage = protocolName + kMsgHelloBackArgs;
|
||||
ProtocolUtil::writef(m_stream, helloBackMessage.c_str(), kProtocolMajorVersion, kProtocolMinorVersion, &m_name);
|
||||
ProtocolUtil::writef(m_stream, helloBackMessage.c_str(), kProtocolMajorVersion, helloBackMinor, &m_name);
|
||||
|
||||
// now connected but waiting to complete handshake
|
||||
setupScreen();
|
||||
|
|
|
|||
Loading…
Reference in a new issue