// // EntityScriptServerLogClient.h // interface/src // // Created by Clement Brisset on 2/1/17. // Copyright 2017 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_EntityScriptServerLogClient_h #define hifi_EntityScriptServerLogClient_h #include #include #include /*@jsdoc * The EntityScriptServerLog API makes server log file output written by server entity scripts available to client * scripts. * * @namespace EntityScriptServerLog * * @hifi-interface * @hifi-client-entity * @hifi-avatar */ class EntityScriptServerLogClient : public QObject, public Dependency { Q_OBJECT public: EntityScriptServerLogClient(); /** * @brief This is called by ScriptEngines when scripts need access to entity server script messages and when access * is not needed anymore. */ void requestMessagesForScriptEngines(bool areMessagesRequested); signals: /*@jsdoc * Triggered when one or more lines are written to the server log by server entity scripts. * @function EntityScriptServerLog.receivedNewLogLines * @param {string} logLines - The server log lines written by server entity scripts. If there are multiple lines they are * separated by "\n"s. * @example Echo server entity script program log output to Interface's program log. * EntityScriptServerLog.receivedNewLogLines.connect(function (logLines) { * print("Log lines from server entity scripts:", logLines); * }); * @example A server entity script to test with. Copy the code into an entity's "Server Script" property. * (function () { * print("Hello from a server entity script!"); * }) */ void receivedNewLogLines(QString logLines); protected: void connectNotify(const QMetaMethod& signal) override; void disconnectNotify(const QMetaMethod& signal) override; private slots: void enableToEntityServerScriptLog(bool enable); void handleEntityServerScriptLogPacket(QSharedPointer message, SharedNodePointer senderNode); void nodeActivated(SharedNodePointer activatedNode); void nodeKilled(SharedNodePointer killedNode); void canRezChanged(bool canRez); void connectionsChanged(); private: std::atomic _areMessagesRequestedByScripts {false}; bool _subscribed { false }; friend class ScriptEngines; }; #endif // hifi_EntityScriptServerLogClient_h