Add logging for adding a PC and offline/online state transitions
This commit is contained in:
parent
9470615c63
commit
8a8b624f47
3 changed files with 32 additions and 17 deletions
|
|
@ -103,7 +103,7 @@ private:
|
|||
|
||||
QString serverInfo;
|
||||
try {
|
||||
serverInfo = http.getServerInfo();
|
||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::NONE);
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -154,6 +154,7 @@ private:
|
|||
while (!isInterruptionRequested()) {
|
||||
bool stateChanged = false;
|
||||
bool online = false;
|
||||
bool wasOnline = m_Computer->state == NvComputer::CS_ONLINE;
|
||||
for (int i = 0; i < TRIES_BEFORE_OFFLINING && !online; i++) {
|
||||
for (auto& address : m_Computer->uniqueAddresses()) {
|
||||
if (isInterruptionRequested()) {
|
||||
|
|
@ -161,6 +162,9 @@ private:
|
|||
}
|
||||
|
||||
if (tryPollComputer(address, stateChanged)) {
|
||||
if (!wasOnline) {
|
||||
qInfo() << m_Computer->name << "is now online at" << m_Computer->activeAddress;
|
||||
}
|
||||
online = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -171,6 +175,7 @@ private:
|
|||
// Note: we don't need to acquire the read lock here,
|
||||
// because we're on the writing thread.
|
||||
if (!online && m_Computer->state != NvComputer::CS_OFFLINE) {
|
||||
qInfo() << m_Computer->name << "is now offline";
|
||||
m_Computer->state = NvComputer::CS_OFFLINE;
|
||||
stateChanged = true;
|
||||
}
|
||||
|
|
@ -411,9 +416,11 @@ private:
|
|||
{
|
||||
NvHTTP http(m_Address);
|
||||
|
||||
qInfo() << "Processing new PC at" << m_Address << "from" << (m_Mdns ? "mDNS" : "user");
|
||||
|
||||
QString serverInfo;
|
||||
try {
|
||||
serverInfo = http.getServerInfo();
|
||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
|
||||
} catch (...) {
|
||||
if (!m_Mdns) {
|
||||
emit computerAddCompleted(false);
|
||||
|
|
@ -449,6 +456,7 @@ private:
|
|||
|
||||
// Tell our client if something changed
|
||||
if (changed) {
|
||||
qInfo() << existingComputer->name << "is now at" << existingComputer->activeAddress;
|
||||
emit computerStateChanged(existingComputer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ NvHTTP::getCurrentGame(QString serverInfo)
|
|||
}
|
||||
|
||||
QString
|
||||
NvHTTP::getServerInfo()
|
||||
NvHTTP::getServerInfo(NvLogLevel logLevel)
|
||||
{
|
||||
QString serverInfo;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ NvHTTP::getServerInfo()
|
|||
"serverinfo",
|
||||
nullptr,
|
||||
true,
|
||||
true);
|
||||
logLevel);
|
||||
// Throws if the request failed
|
||||
verifyResponseStatus(serverInfo);
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ NvHTTP::getServerInfo()
|
|||
"serverinfo",
|
||||
nullptr,
|
||||
true,
|
||||
true);
|
||||
logLevel);
|
||||
verifyResponseStatus(serverInfo);
|
||||
}
|
||||
else
|
||||
|
|
@ -189,7 +189,7 @@ NvHTTP::quitApp()
|
|||
|
||||
// Newer GFE versions will just return success even if quitting fails
|
||||
// if we're not the original requestor.
|
||||
if (getCurrentGame(getServerInfo()) != 0) {
|
||||
if (getCurrentGame(getServerInfo(NvHTTP::ERROR)) != 0) {
|
||||
// Generate a synthetic GfeResponseException letting the caller know
|
||||
// that they can't kill someone else's stream.
|
||||
throw GfeHttpResponseException(599, "");
|
||||
|
|
@ -230,7 +230,7 @@ NvHTTP::getAppList()
|
|||
"applist",
|
||||
nullptr,
|
||||
true,
|
||||
true);
|
||||
NvLogLevel::ERROR);
|
||||
verifyResponseStatus(appxml);
|
||||
|
||||
QXmlStreamReader xmlReader(appxml);
|
||||
|
|
@ -297,7 +297,8 @@ NvHTTP::getBoxArt(int appId)
|
|||
"appasset",
|
||||
"appid="+QString::number(appId)+
|
||||
"&AssetType=2&AssetIdx=0",
|
||||
true);
|
||||
true,
|
||||
NvLogLevel::VERBOSE);
|
||||
QImage image = QImageReader(reply).read();
|
||||
delete reply;
|
||||
|
||||
|
|
@ -344,9 +345,9 @@ NvHTTP::openConnectionToString(QUrl baseUrl,
|
|||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
bool suppressLogging)
|
||||
NvLogLevel logLevel)
|
||||
{
|
||||
QNetworkReply* reply = openConnection(baseUrl, command, arguments, enableTimeout, suppressLogging);
|
||||
QNetworkReply* reply = openConnection(baseUrl, command, arguments, enableTimeout, logLevel);
|
||||
QString ret;
|
||||
|
||||
QTextStream stream(reply);
|
||||
|
|
@ -362,7 +363,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
|||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
bool suppressLogging)
|
||||
NvLogLevel logLevel)
|
||||
{
|
||||
// Build a URL for the request
|
||||
QUrl url(baseUrl);
|
||||
|
|
@ -388,7 +389,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
|||
{
|
||||
QTimer::singleShot(REQUEST_TIMEOUT_MS, &loop, SLOT(quit()));
|
||||
}
|
||||
if (!suppressLogging) {
|
||||
if (logLevel >= NvLogLevel::VERBOSE) {
|
||||
qInfo() << "Executing request:" << url.toString();
|
||||
}
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
|
|
@ -396,7 +397,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
|||
// Abort the request if it timed out
|
||||
if (!reply->isFinished())
|
||||
{
|
||||
if (!suppressLogging) {
|
||||
if (logLevel >= NvLogLevel::ERROR) {
|
||||
qWarning() << "Aborting timed out request for" << url.toString();
|
||||
}
|
||||
reply->abort();
|
||||
|
|
@ -409,7 +410,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
|||
// Handle error
|
||||
if (reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
if (!suppressLogging) {
|
||||
if (logLevel >= NvLogLevel::ERROR) {
|
||||
qWarning() << command << " request failed with error " << reply->error();
|
||||
}
|
||||
GfeHttpResponseException exception(reply->error(), reply->errorString());
|
||||
|
|
|
|||
|
|
@ -80,6 +80,12 @@ private:
|
|||
class NvHTTP
|
||||
{
|
||||
public:
|
||||
enum NvLogLevel {
|
||||
NONE,
|
||||
ERROR,
|
||||
VERBOSE
|
||||
};
|
||||
|
||||
explicit NvHTTP(QString address);
|
||||
|
||||
static
|
||||
|
|
@ -87,7 +93,7 @@ public:
|
|||
getCurrentGame(QString serverInfo);
|
||||
|
||||
QString
|
||||
getServerInfo();
|
||||
getServerInfo(NvLogLevel logLevel);
|
||||
|
||||
static
|
||||
void
|
||||
|
|
@ -108,7 +114,7 @@ public:
|
|||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
bool suppressLogging = false);
|
||||
NvLogLevel logLevel = NvLogLevel::VERBOSE);
|
||||
|
||||
static
|
||||
QVector<int>
|
||||
|
|
@ -145,7 +151,7 @@ private:
|
|||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
bool suppressLogging = false);
|
||||
NvLogLevel logLevel);
|
||||
|
||||
QString m_Address;
|
||||
QNetworkAccessManager m_Nam;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue