History

Add unfinished OSCScriptingInterface

Ada committed 11 months ago

Commit 2faebb91 parent 0e1eb0b2 files · +237 −0Browse files

Showing the changes to interface/src/scripting/OSCScriptingInterface.h (1 of 2 files). Show all

Unified · Split

interface/src/scripting/OSCScriptingInterface.h+63−0
@@ -0,0 +1,63 @@
1//
2// OSCScriptingInterface.h
3// interface/src/scripting
4//
5// Created by Ada <ada@thingvellir.net> on 2025-12-13
6// Copyright 2025 Overte e.V.
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_OSCScriptingInterface_h
13#define hifi_OSCScriptingInterface_h
14
15#include <QObject>
16#include <QUdpSocket>
17
18#include "SettingHandle.h"
19#include "ScriptManager.h"
20
21class OSCScriptingInterface : public QObject {
22 Q_OBJECT
23
24 void receivePacket();
25public:
26 OSCScriptingInterface(ScriptManager* parent);
27 ~OSCScriptingInterface();
28
29 /*@jsdoc
30 * Sends an encoded OSC message. The target host address and port are visible as the <code>osc/sendHost</code> and <code>osc/sendPort</code> settings.
31 * @function OSCSocket.sendMessage
32 * @param {string} address - The OSC address, starting with <code>/</code>
33 * @param {string} argumentTypes - A string of the data types contained in <code>arguments</code>.
34 * Supports the <code>i</code> (32-bit integer), <code>f</code> (32-bit float),
35 * <code>s</code> (null-terminated string), <code>b</code> (ArrayBuffer), <code>T</code> (boolean true), and <code>F</code> (boolean false) tag types. The string should not be prefixed with a comma. May be left empty for no arguments.
36 * @param {Array.<*>} [arguments] - OSC arguments.
37 */
38 Q_INVOKABLE void sendMessage(const QString& address, const QString& argumentTypes = QString(), const QVariantList& arguments = QVariantList());
39
40signals:
41 /*@jsdoc
42 * Triggered when an OSC datagram is received. The receiving host address and port are visible as the <code>osc/receiveHost</code> and <code>osc/receivePort</code> settings.
43 * @function OSCSocket.messageReceived
44 * @param {string} address - OSC address starting with <code>/</code>
45 * @param {string} argumentTypes - String of OSC data types contained by <code>arguments</code>
46 * @param {Array.<*>} arguments
47 * @returns {Signal}
48 */
49 void messageReceived(const QString& address, const QString& argumentTypes, const QVariantList& arguments);
50
51private:
52 ScriptManager* _scriptManager;
53
54 Setting::Handle<int> _receivePort;
55 Setting::Handle<QString> _receiveHost;
56
57 Setting::Handle<int> _sendPort;
58 Setting::Handle<QString> _sendHost;
59
60 std::shared_ptr<QUdpSocket> _socket;
61};
62
63#endif