Connect/disconnect and join game/room intents.

Took 3 hours 14 minutes

Took 2 seconds

Took 15 seconds
This commit is contained in:
Lukas Brübach 2026-04-14 07:27:00 +02:00
parent a1cc420033
commit bbdf706e5e
26 changed files with 514 additions and 3 deletions

View file

@ -0,0 +1,47 @@
#ifndef COCKATRICE_INTENT_DISCONNECT_FROM_SERVER_H
#define COCKATRICE_INTENT_DISCONNECT_FROM_SERVER_H
#include "intent.h"
#include "remote_client.h"
class IntentDisconnectFromServer : public Intent
{
Q_OBJECT
public:
IntentDisconnectFromServer(RemoteClient *_remoteClient) : Intent(), remoteClient(_remoteClient)
{
}
protected:
bool checkPrecondition() const override
{
return remoteClient->getStatus() == ClientStatus::StatusDisconnected;
}
void onPreconditionSatisfied() override
{
qWarning() << "Client disconnected, disconnect is finished";
emit finished();
}
void onPreconditionNotSatisfied() override
{
qWarning() << "Client not disconnected, hooking up signal and disconnecting." << remoteClient->getStatus();
connect(remoteClient, &RemoteClient::statusChanged, this, &IntentDisconnectFromServer::onStatusChanged);
remoteClient->disconnectFromServer();
}
private:
RemoteClient *remoteClient;
private slots:
void onStatusChanged(ClientStatus status)
{
qWarning() << "Client Status changed: " << status;
if (status == ClientStatus::StatusDisconnected) {
qWarning() << "Client disconnected, finished";
emit finished();
}
}
};
#endif // COCKATRICE_INTENT_DISCONNECT_FROM_SERVER_H