Web: [skip ci] implement blocking tcp server
This commit is contained in:
@@ -151,6 +151,14 @@ void AppServer::customEvent(QEvent* e)
|
||||
QByteArray msg = ev->request();
|
||||
QTcpSocket* socket = ev->socket();
|
||||
|
||||
std::string str = runPython(msg);
|
||||
|
||||
socket->write(str.c_str());
|
||||
socket->close();
|
||||
}
|
||||
|
||||
std::string AppServer::runPython(const QByteArray& msg)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
try {
|
||||
@@ -175,8 +183,7 @@ void AppServer::customEvent(QEvent* e)
|
||||
str = "Unknown exception thrown";
|
||||
}
|
||||
|
||||
socket->write(str.c_str());
|
||||
socket->close();
|
||||
return str;
|
||||
}
|
||||
|
||||
#include "moc_Server.cpp"
|
||||
|
||||
Reference in New Issue
Block a user