{
peer->connect(m_host, m_hostPort);
peer->call("auth", m_user, m_pass);
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[CLIENT] CALL auth" << m_user << m_pass;
+#endif
}
void ProxyClient::disconnect(bool graceful)
Command cmd = reply->command().rawCommand();
peer->call("sendCommand", reply->id(), buildCmd(cmd.first, cmd.second));
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[CLIENT] CALL sendCommand" << reply->id() << buildCmd(cmd.first, cmd.second);
+#endif
if (!reply->command().waitForResult())
delete reply;
}
void ProxyClient::cancel(AbstractReply *command)
{
peer->call("cancel", command->id());
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[CLIENT] CALL cancel";
+#endif
}
void ProxyClient::replyRecieved(const QByteArray &id, int replyCodeAsInt, const QString &reply)
{
ReplyCode replyCode = (ReplyCode) replyCodeAsInt;
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[CLIENT] RECV replyRecieved" << id << replyCode << reply;
+#endif
AbstractReply *command = commands.value(id, 0);
if (!command)
void ProxyClient::errorRecieved(int errorAsInt)
{
Error error = (Error) errorAsInt;
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[CLIENT] RECV errorRecieved" << error;
+#endif
m_error = error;
emit connectionError();
}
void ProxyServer::auth(quint64 client, const QString &user, const QString &pass)
{
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[SERVER] RECV auth" << client << user << pass;
+#endif
if (isAuthed(client))
return;
if (m_user != user || m_pass != pass)
{
peer->call(client, "errorRecieved", (int) AuthenticationError);
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[SERVER] CALL errorRecieved" << AuthenticationError;
+#endif
peer->disconnectClient(client);
return;
}
clientInfo[client].authed = true;
- qDebug() << "[SERVER] Auth successful" << client;
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
+qDebug() << "[SERVER] Auth successful" << client;
+#endif
}
void ProxyServer::sendCommand(quint64 client, const QByteArray &id, const QByteArray &rawCommand)
{
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[SERVER] RECV sendCommand" << client << id << rawCommand;
+#endif
if (!isAuthed(client))
return;
void ProxyServer::clientConnected(quint64 client)
{
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "client connected" << client;
clientInfo.insert(client, ClientInfo());
+#endif
}
void ProxyServer::clientDisconnected(quint64 client)
{
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[SERVER] RECV client disconnected" << client;
+#endif
for (QMap<QByteArray, quint64>::iterator i = clientCommands.begin(); i != clientCommands.end(); )
{
if (i.value() != client)
idMapping.remove(id);
peer->call(client, "replyRecieved", id, (int) reply->replyCode(), reply->rawReply());
+#ifdef ANIDBUDPCLIENT_PROXY_DEBUG
qDebug() << "[SERVER] CALL replyRecieved" << id << reply->replyCode() << reply->rawReply();
+#endif
reply->deleteLater();
}