Move WebSocket to Webserver & HttpJsonRpc async (#486)

* Move WebSocket to Webserver and HttpJsonRpc is now async

* revert...
This commit is contained in:
brindosch
2017-11-20 00:06:45 +01:00
committed by GitHub
parent 9799fae7f9
commit 0f9f3a17e7
19 changed files with 733 additions and 722 deletions

View File

@@ -57,21 +57,23 @@ uint16_t JsonServer::getPort() const
void JsonServer::newConnection()
{
QTcpSocket * socket = _server.nextPendingConnection();
if (socket != nullptr)
while(_server.hasPendingConnections())
{
Debug(_log, "New connection from: %s ",socket->localAddress().toString().toStdString().c_str());
JsonClientConnection * connection = new JsonClientConnection(socket);
_openConnections.insert(connection);
if (QTcpSocket * socket = _server.nextPendingConnection())
{
Debug(_log, "New connection from: %s ",socket->localAddress().toString().toStdString().c_str());
JsonClientConnection * connection = new JsonClientConnection(socket);
_openConnections.insert(connection);
// register slot for cleaning up after the connection closed
connect(connection, SIGNAL(connectionClosed(JsonClientConnection*)), this, SLOT(closedConnection(JsonClientConnection*)));
// register slot for cleaning up after the connection closed
connect(connection, &JsonClientConnection::connectionClosed, this, &JsonServer::closedConnection);
}
}
}
void JsonServer::closedConnection(JsonClientConnection *connection)
void JsonServer::closedConnection(void)
{
JsonClientConnection* connection = qobject_cast<JsonClientConnection*>(sender());
Debug(_log, "Connection closed");
_openConnections.remove(connection);