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