Пример #1
0
void MainWindow::on_Conectar_clicked()
{
    this->c = new Client(ui->HostInput->currentText(), ui->PortaInput->text().toInt());

    connect(c, SIGNAL(connectionSuccessful()), this, SLOT(on_connection_successful()));
    connect(c, SIGNAL(hasReadData()), this, SLOT(on_data_received()));

    //ui->HostInput->setEnabled(false);
    //ui->PortaInput->setEnabled(false);
}
Пример #2
0
bool Client::connectToServer(QHostAddress &addr, quint16 port)
{
	QString addrString = addr.toString();
	connection = QSharedPointer<TextShredderConnection>(new TextShredderConnection(this, addrString, port, false));

	connect(connection.data(), SIGNAL(clientDisconnected()),
			this, SLOT(connectionDidEncounterEnd()));
	connect(connection.data(), SIGNAL(socketConnectedSuccessfully()),
			this, SLOT(connectionSuccessful()));
	connect(connection.data(), SIGNAL(socketErrorReceived(QAbstractSocket::SocketError)),
			this, SLOT(connectionError(QAbstractSocket::SocketError)));
	connect(connection.data(), SIGNAL(incomingSyncableFilesPacket(QByteArray&)),
			FileManager::Instance(), SLOT(handleReceivedSyncableFiles(QByteArray &)));
	connect(connection.data(), SIGNAL(incomingOnlineUsersPacket(TextShredderPacket&)),
			this, SLOT(connectionReceivedOnlineUsersPacket(TextShredderPacket &)));
	connection.data()->startConnection();
	return true;
}