/// \brief New connexion void ServerCatchcopy::newConnection() { while(server.hasPendingConnections()) { QLocalSocket *clientSocket = server.nextPendingConnection(); if(clientSocket!=NULL) { do { idNextClient++; if(idNextClient>2000000000) idNextClient=0; } while(clientIdFound(idNextClient)); Client newClient; newClient.id = idNextClient; newClient.socket = clientSocket; newClient.haveData = false; newClient.firstProtocolReplied = false; newClient.detectTimeOut = new QTimer(this); newClient.detectTimeOut->setSingleShot(true); newClient.detectTimeOut->setInterval(CATCHCOPY_COMMUNICATION_TIMEOUT); newClient.name="Unknown"; connect(newClient.socket, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error), this, &ServerCatchcopy::connectionError,Qt::QueuedConnection); connect(newClient.socket, &QIODevice::readyRead, this, &ServerCatchcopy::readyRead,Qt::QueuedConnection); connect(newClient.socket, &QLocalSocket::disconnected, this, &ServerCatchcopy::disconnected,Qt::QueuedConnection); connect(newClient.detectTimeOut,&QTimer::timeout, this, &ServerCatchcopy::checkTimeOut,Qt::QueuedConnection); clientList << newClient; emit connectedClient(newClient.id); } } }
/// \brief New connexion void ServerCatchcopy::newConnection() { while(server.hasPendingConnections()) { QLocalSocket *clientSocket = server.nextPendingConnection(); if(clientSocket!=NULL) { do { idNextClient++; if(idNextClient>2000000000) idNextClient=0; } while(clientIdFound(idNextClient)); Client newClient; newClient.id = idNextClient; newClient.socket = clientSocket; newClient.haveData = false; newClient.firstProtocolReplied = false; newClient.detectTimeOut = new QTimer(this); newClient.detectTimeOut->setSingleShot(true); newClient.detectTimeOut->setInterval(CATCHCOPY_COMMUNICATION_TIMEOUT); connect(newClient.socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(connectionError(QLocalSocket::LocalSocketError))); connect(newClient.socket, SIGNAL(readyRead()), this, SLOT(readyRead())); connect(newClient.socket, SIGNAL(disconnected()), this, SLOT(disconnected())); connect(newClient.detectTimeOut,SIGNAL(timeout()), this, SLOT(checkTimeOut())); ClientList << newClient; emit connectedClient(newClient.id); } } }