connectedHistoryState->setDefaultState(sendState);
// ------------- Transitions ---------------------
+ errorState->addTransition(this, SIGNAL(clearErrorsRequested()), disconnectedState);
+ errorState->addTransition(this, SIGNAL(startConnecting()), connectingState);
+
connectedState->addTransition(this, SIGNAL(startDisconnecting()), disconnectedState);
connectedState->addTransition(socket, SIGNAL(readyRead()), recieveState);
connectedState->addTransition(this, SIGNAL(sendFailed()), recieveFailState);
disconnectedState->addTransition(this, SIGNAL(startConnecting()), connectingState);
connectingState->addTransition(this, SIGNAL(connected()), connectedState);
+ connectingState->addTransition(this, SIGNAL(connectionError()), errorState);
authenticatingState->addTransition(this, SIGNAL(startSending()), sendState);
authenticatingState->addTransition(this, SIGNAL(authenticated()), sendState);
// ------------- Methods ---------------------
QObject::connect(errorState, SIGNAL(entered()), this, SLOT(enterErrorState()));
+ QObject::connect(errorState, SIGNAL(exited()), this, SLOT(exitErrorState()));
QObject::connect(disconnectedState, SIGNAL(entered()), this, SLOT(enterDisconnectedState()));
QObject::connect(connectingState, SIGNAL(entered()), this, SLOT(enterConnectingState()));
QObject::connect(connectedState, SIGNAL(entered()), this, SLOT(enterConnectedState()));
disconnect();
}
+void Client::exitErrorState()
+{
+#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG
+qDebug() << "Exiting Error State";
+#endif
+ m_error = NoError;
+ m_errorString = QString();
+}
+
void Client::enterDisconnectedState()
{
#ifdef ANIDBUDPCLIENT_CLIENT_STATE_MACHINE_DEBUG
#endif
if (socket->state() == QAbstractSocket::BoundState)
socket->disconnectFromHost();
+ commandsTimedOut = 0;
+ m_hostAddress = QHostAddress();
m_salt.clear();
usingEncryption = false;
}
sentCommands.remove(reply->id());
}
+void Client::clearErrors()
+{
+ emit clearErrorsRequested();
+}
+
void Client::logout()
{
logout(false);
void sendRaw(QByteArray command);
void cancel(AbstractReply *command);
+ void clearErrors();
+
signals:
void newVersionAvailable();
void replyRecieved();
void sendFailed();
+ void clearErrorsRequested();
+
void model_queuedCommandAdded(int index);
void model_queuedCommandRemoved(int index);
void model_sentCommandAdded(int index);
private slots:
void enterErrorState();
+ void exitErrorState();
void enterDisconnectedState();
void enterConnectingState();
// Misc params
IdlePolicy m_idlePolicy;
- Error m_error;
bool disconnecting;
bool authenticatingStarted;