mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 08:52:19 -07:00
Connect/disconnect and join game/room intents.
Took 3 hours 14 minutes Took 2 seconds Took 15 seconds
This commit is contained in:
parent
a1cc420033
commit
bbdf706e5e
26 changed files with 514 additions and 3 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue