Showing the changes to libraries/networking/src/EntityScriptClient.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | #include "EntityScriptClient.h" |
| 2 | 2 | #include "NodeList.h" |
| 3 | 3 | #include "NetworkLogging.h" |
| 4 | +#include "EntityScriptUtils.h" | |
| 4 | 5 | |
| 5 | 6 | #include <QThread> |
| 6 | 7 | |
| @@ -15,9 +16,12 @@ GetScriptStatusRequest::~GetScriptStatusRequest() { · 8 unmodified lines | ||
| 15 | 16 | |
| 16 | 17 | void GetScriptStatusRequest::start() { |
| 17 | 18 | auto client = DependencyManager::get<EntityScriptClient>(); |
| 18 | − qDebug() << "Sending script status request"; | |
| 19 | − client->getEntityServerScriptStatus(_entityID, [this](bool responseReceived) { | |
| 20 | − qDebug() << "Received script status request"; | |
| 19 | + client->getEntityServerScriptStatus(_entityID, [this](bool responseReceived, bool isRunning, EntityScriptStatus status, QString errorInfo) { | |
| 20 | + this->responseReceived = responseReceived; | |
| 21 | + this->isRunning = isRunning; | |
| 22 | + this->status = status; | |
| 23 | + this->errorInfo = errorInfo; | |
| 24 | + | |
| 21 | 25 | emit finished(this); |
| 22 | 26 | }); |
| 23 | 27 | } |
| @@ -84,7 +88,7 @@ MessageID EntityScriptClient::getEntityServerScriptStatus(QUuid entityID, GetScr · 60 unmodified lines | ||
| 84 | 88 | } |
| 85 | 89 | } |
| 86 | 90 | |
| 87 | − callback(false); | |
| 91 | + callback(false, false, ERROR_LOADING_SCRIPT, ""); | |
| 88 | 92 | return INVALID_MESSAGE_ID; |
| 89 | 93 | } |
| 90 | 94 | |
| @@ -92,9 +96,17 @@ void EntityScriptClient::handleGetScriptStatusReply(QSharedPointer<ReceivedMessa · 1 unmodified line | ||
| 92 | 96 | Q_ASSERT(QThread::currentThread() == thread()); |
| 93 | 97 | |
| 94 | 98 | MessageID messageID; |
| 99 | + bool isKnown { false }; | |
| 100 | + EntityScriptStatus status = ERROR_LOADING_SCRIPT; | |
| 101 | + QString errorInfo { "" }; | |
| 102 | + | |
| 95 | 103 | message->readPrimitive(&messageID); |
| 104 | + message->readPrimitive(&isKnown); | |
| 96 | 105 | |
| 97 | − auto status = message->readString(); | |
| 106 | + if (isKnown) { | |
| 107 | + message->readPrimitive(&status); | |
| 108 | + errorInfo = message->readString(); | |
| 109 | + } | |
| 98 | 110 | |
| 99 | 111 | // Check if we have any pending requests for this node |
| 100 | 112 | auto messageMapIt = _pendingEntityScriptStatusRequests.find(senderNode); |
| @@ -107,7 +119,7 @@ void EntityScriptClient::handleGetScriptStatusReply(QSharedPointer<ReceivedMessa · 6 unmodified lines | ||
| 107 | 119 | auto requestIt = messageCallbackMap.find(messageID); |
| 108 | 120 | if (requestIt != messageCallbackMap.end()) { |
| 109 | 121 | auto callback = requestIt->second; |
| 110 | − callback(true); | |
| 122 | + callback(true, isKnown, status, errorInfo); | |
| 111 | 123 | messageCallbackMap.erase(requestIt); |
| 112 | 124 | } |
| 113 | 125 | |
| @@ -145,7 +157,7 @@ void EntityScriptClient::forceFailureOfPendingRequests(SharedNodePointer node) { · 31 unmodified lines | ||
| 145 | 157 | auto messageMapIt = _pendingEntityScriptStatusRequests.find(node); |
| 146 | 158 | if (messageMapIt != _pendingEntityScriptStatusRequests.end()) { |
| 147 | 159 | for (const auto& value : messageMapIt->second) { |
| 148 | − value.second(false); | |
| 160 | + value.second(false, false, ERROR_LOADING_SCRIPT, ""); | |
| 149 | 161 | } |
| 150 | 162 | messageMapIt->second.clear(); |
| 151 | 163 | } |