Use TCP as default transport layer for clients

This commit is contained in:
Simon Stürz 2022-03-09 17:05:34 +01:00
parent 45b1d4400f
commit 5d5f433b4f
2 changed files with 10 additions and 9 deletions

View File

@ -104,8 +104,8 @@ int main(int argc, char *argv[])
.arg(API_VERSION_STRING) .arg(API_VERSION_STRING)
.arg(QChar(0xA9))); .arg(QChar(0xA9)));
QCommandLineOption urlOption(QStringList() << "u" << "url", "The proxy server url. Default wss://dev-remoteproxy.nymea.io:443", "url"); QCommandLineOption urlOption(QStringList() << "u" << "url", "The proxy server url. Default ssl://dev-remoteproxy.nymea.io:4433", "url");
urlOption.setDefaultValue("wss://dev-remoteproxy.nymea.io:443"); urlOption.setDefaultValue("ssl://dev-remoteproxy.nymea.io:4433");
parser.addOption(urlOption); parser.addOption(urlOption);
QCommandLineOption tokenOption(QStringList() << "t" << "token", "The AWS token for authentication.", "token"); QCommandLineOption tokenOption(QStringList() << "t" << "token", "The AWS token for authentication.", "token");
@ -128,8 +128,8 @@ int main(int argc, char *argv[])
QCommandLineOption uuidOption(QStringList() << "uuid", "The uuid of the client. If not specified, a new one will be created", "uuid"); QCommandLineOption uuidOption(QStringList() << "uuid", "The uuid of the client. If not specified, a new one will be created", "uuid");
parser.addOption(uuidOption); parser.addOption(uuidOption);
QCommandLineOption tcpOption(QStringList() << "tcp", "Use TCP as tronsport instead of web sockets."); QCommandLineOption wsOption(QStringList() << "ws", "Use web socket as tronsport instead of TCP sockets.");
parser.addOption(tcpOption); parser.addOption(wsOption);
QCommandLineOption verboseOption(QStringList() << "verbose", "Print more information about the connection."); QCommandLineOption verboseOption(QStringList() << "verbose", "Print more information about the connection.");
parser.addOption(verboseOption); parser.addOption(verboseOption);
@ -171,14 +171,15 @@ int main(int argc, char *argv[])
} }
ProxyClient *client = nullptr; ProxyClient *client = nullptr;
if (parser.isSet(tcpOption)) { if (parser.isSet(wsOption)) {
qCDebug(dcProxyClient()) << "Using TCP as transport layer"; qCDebug(dcProxyClient()) << "Using web sockets as transport layer";
client = new ProxyClient(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeTcpSocket); client = new ProxyClient(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeWebSocket);
client->setInsecure(parser.isSet(insecureOption)); client->setInsecure(parser.isSet(insecureOption));
client->setPingpong(parser.isSet(pingPongOption)); client->setPingpong(parser.isSet(pingPongOption));
client->start(serverUrl, parser.value(tokenOption), parser.value(nonceOption)); client->start(serverUrl, parser.value(tokenOption), parser.value(nonceOption));
} else { } else {
client = new ProxyClient(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeWebSocket); qCDebug(dcProxyClient()) << "Using TCP as transport layer";
client = new ProxyClient(parser.value(nameOption), uuid, RemoteProxyConnection::ConnectionTypeTcpSocket);
client->setInsecure(parser.isSet(insecureOption)); client->setInsecure(parser.isSet(insecureOption));
client->setPingpong(parser.isSet(pingPongOption)); client->setPingpong(parser.isSet(pingPongOption));
client->start(serverUrl, parser.value(tokenOption), parser.value(nonceOption)); client->start(serverUrl, parser.value(tokenOption), parser.value(nonceOption));

View File

@ -97,7 +97,7 @@ public:
private: private:
QUuid m_clientUuid; QUuid m_clientUuid;
QString m_clientName; QString m_clientName;
ConnectionType m_connectionType = ConnectionTypeWebSocket; ConnectionType m_connectionType = ConnectionTypeTcpSocket;
QUrl m_serverUrl; QUrl m_serverUrl;