Overte C++ Documentation
EntityScriptServerLogClient.h
1 //
2 // EntityScriptServerLogClient.h
3 // interface/src
4 //
5 // Created by Clement Brisset on 2/1/17.
6 // Copyright 2017 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_EntityScriptServerLogClient_h
13 #define hifi_EntityScriptServerLogClient_h
14 
15 #include <QObject>
16 #include <QtCore/QSharedPointer>
17 
18 #include <NodeList.h>
19 
20 /*@jsdoc
21  * The <code>EntityScriptServerLog</code> API makes server log file output written by server entity scripts available to client
22  * scripts.
23  *
24  * @namespace EntityScriptServerLog
25  *
26  * @hifi-interface
27  * @hifi-client-entity
28  * @hifi-avatar
29  */
30 class EntityScriptServerLogClient : public QObject, public Dependency {
31  Q_OBJECT
32 
33 public:
34  EntityScriptServerLogClient();
35 
40  void requestMessagesForScriptEngines(bool areMessagesRequested);
41 
42 signals:
43 
44  /*@jsdoc
45  * Triggered when one or more lines are written to the server log by server entity scripts.
46  * @function EntityScriptServerLog.receivedNewLogLines
47  * @param {string} logLines - The server log lines written by server entity scripts. If there are multiple lines they are
48  * separated by <code>"\n"</code>s.
49  * @example <caption>Echo server entity script program log output to Interface's program log.</caption>
50  * EntityScriptServerLog.receivedNewLogLines.connect(function (logLines) {
51  * print("Log lines from server entity scripts:", logLines);
52  * });
53  * @example <caption>A server entity script to test with. Copy the code into an entity's "Server Script" property.</caption>
54  * (function () {
55  * print("Hello from a server entity script!");
56  * })
57  */
58  void receivedNewLogLines(QString logLines);
59 
60 protected:
61  void connectNotify(const QMetaMethod& signal) override;
62  void disconnectNotify(const QMetaMethod& signal) override;
63 
64 private slots:
65  void enableToEntityServerScriptLog(bool enable);
66  void handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
67 
68  void nodeActivated(SharedNodePointer activatedNode);
69  void nodeKilled(SharedNodePointer killedNode);
70  void canRezChanged(bool canRez);
71 
72  void connectionsChanged();
73 
74 private:
75  std::atomic<bool> _areMessagesRequestedByScripts {false};
76  bool _subscribed { false };
77 
78  friend class ScriptEngines;
79 };
80 
81 #endif // hifi_EntityScriptServerLogClient_h
Provides the ScriptDiscoveryService scripting interface.
Definition: ScriptEngines.h:59