| 190 | } |
| 191 | |
| 192 | void LocalPeer::receiveConnection() |
| 193 | { |
| 194 | QLocalSocket* socket = server->nextPendingConnection(); |
| 195 | if (!socket) { |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | while (socket->bytesAvailable() < static_cast<int>(sizeof(quint32))) { |
| 200 | socket->waitForReadyRead(); |
| 201 | } |
| 202 | QDataStream ds(socket); |
| 203 | QByteArray uMsg; |
| 204 | quint32 remaining; |
| 205 | ds >> remaining; |
| 206 | uMsg.resize(remaining); |
| 207 | int got = 0; |
| 208 | char* uMsgBuf = uMsg.data(); |
| 209 | do { |
| 210 | got = ds.readRawData(uMsgBuf, remaining); |
| 211 | remaining -= got; |
| 212 | uMsgBuf += got; |
| 213 | } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); |
| 214 | if (got < 0) { |
| 215 | qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); |
| 216 | delete socket; |
| 217 | return; |
| 218 | } |
| 219 | socket->write(ack, qstrlen(ack)); |
| 220 | socket->waitForBytesWritten(1000); |
| 221 | socket->waitForDisconnected(1000); // make sure client reads ack |
| 222 | delete socket; |
| 223 | emit messageReceived(uMsg); // ### (might take a long time to return) |
| 224 | } |
nothing calls this directly
no test coverage detected