tahoma2d/toonz/sources/toonzfarm/tfarm/tfarmproxy.cpp

53 lines
1.2 KiB
C++
Raw Normal View History

2016-03-19 06:57:51 +13:00
#include "tconvert.h"
#include "tfarmproxy.h"
#include "ttcpip.h"
#include <QStringList>
//------------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
QString TFarmProxy::sendToStub(const QString &data) {
TTcpIpClient client;
int sock;
int ret = client.connect(m_hostName, m_addr, m_port, sock);
if (ret != OK) {
throw CantConnectToStub(m_hostName, m_addr, m_port);
}
QString reply;
ret = client.send(sock, data, reply);
if (ret != OK) {
client.disconnect(sock);
throw CantConnectToStub(m_hostName, m_addr, m_port);
}
client.disconnect(sock);
return reply;
2016-03-19 06:57:51 +13:00
}
//------------------------------------------------------------------------------
int TFarmProxy::extractArgs(const QString &s, std::vector<QString> &argv) {
2016-06-15 18:43:10 +12:00
argv.clear();
if (s == "") return 0;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QStringList sl = s.split(',');
int i;
for (i = 0; i < sl.size(); i++) argv.push_back(sl.at(i));
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
return argv.size();
2016-03-19 06:57:51 +13:00
}
//==============================================================================
2016-06-15 18:43:10 +12:00
TString CantConnectToStub::getMessage() const {
std::string msg("Unable to connect to ");
2016-06-15 18:43:10 +12:00
msg += m_hostName.toStdString();
msg += " on port ";
msg += std::to_string(m_port);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
return ::to_wstring(msg);
2016-03-19 06:57:51 +13:00
}