14 #ifndef hifi_EntityScriptClient_h
15 #define hifi_EntityScriptClient_h
17 #include <QtCore/QSharedPointer>
19 #include <ClientServerUtils.h>
20 #include <LimitedNodeList.h>
21 #include <ReceivedMessage.h>
22 #include <AssetUtils.h>
23 #include "EntityScriptUtils.h"
25 #include <DependencyManager.h>
26 #include <unordered_map>
28 using GetScriptStatusCallback = std::function<void(
bool responseReceived,
bool isRunning, EntityScriptStatus status, QString errorInfo)>;
30 class GetScriptStatusRequest :
public QObject {
33 GetScriptStatusRequest(QUuid);
34 ~GetScriptStatusRequest();
36 Q_INVOKABLE
void start();
38 bool getResponseReceived()
const {
return _responseReceived; }
39 bool getIsRunning()
const {
return _isRunning; }
40 EntityScriptStatus getStatus()
const {
return _status; }
41 QString getErrorInfo()
const {
return _errorInfo; }
44 void finished(GetScriptStatusRequest* request);
50 bool _responseReceived;
52 EntityScriptStatus _status;
56 class EntityScriptClient :
public QObject,
public Dependency {
61 Q_INVOKABLE GetScriptStatusRequest* createScriptStatusRequest(QUuid entityID);
63 bool reloadServerScript(QUuid entityID);
64 MessageID getEntityServerScriptStatus(QUuid entityID, GetScriptStatusCallback callback);
65 void callEntityServerMethod(QUuid
id,
const QString& method,
const QStringList& params);
69 void handleNodeKilled(SharedNodePointer node);
70 void handleNodeClientConnectionReset(SharedNodePointer node);
72 void handleGetScriptStatusReply(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
75 static MessageID _currentID;
76 std::unordered_map<SharedNodePointer, std::unordered_map<MessageID, GetScriptStatusCallback>> _pendingEntityScriptStatusRequests;
78 void forceFailureOfPendingRequests(SharedNodePointer node);
82 class EntityScriptServerServices :
public QObject,
public Dependency {
85 void callEntityClientMethod(QUuid clientSessionID, QUuid entityID,
const QString& method,
const QStringList& params);