2 #include <State/Message.hpp>
4 #include <score/plugins/documentdelegate/plugin/DocumentPlugin.hpp>
5 #include <score/tools/std/StringHash.hpp>
7 #include <ossia/detail/flat_map.hpp>
8 #include <ossia/detail/hash_map.hpp>
10 #include <QtWebSockets/QWebSocket>
11 #include <QtWebSockets/QWebSocketServer>
13 #include <nano_observer.hpp>
14 #include <score_plugin_remotecontrol_export.h>
19 class DeviceExplorerNode;
24 class DeviceDocumentPlugin;
31 namespace RemoteControl
40 return lhs.socket == rhs.socket;
46 ossia::flat_map<QString, std::function<void(
const rapidjson::Value&,
const WSClient&)>>
49 std::function<void(
const std::vector<WSClient>&)> onAdded;
50 std::function<void(
const std::vector<WSClient>&)> onRemoved;
51 std::function<void(
const WSClient&)> onClientConnection;
52 std::function<void(
const WSClient&)> onClientDisconnection;
60 onAdded = [msgs](
const std::vector<RemoteControl::WSClient>& clts) {
61 auto msg = msgs.initMessage();
63 clt.socket->sendTextMessage(msg);
65 onRemoved = [msgs](
const std::vector<RemoteControl::WSClient>& clts) {
66 auto msg = msgs.deinitMessage();
68 clt.socket->sendTextMessage(msg);
72 auto msg = msgs.initMessage();
73 clt.socket->sendTextMessage(msg);
76 auto msg = msgs.deinitMessage();
77 clt.socket->sendTextMessage(msg);
82 struct SCORE_PLUGIN_REMOTECONTROL_EXPORT
Receiver
84 ,
public Nano::Observer
91 void addHandler(QObject* context,
Handler&& handler);
92 void removeHandler(QObject* context);
97 void onNewConnection();
99 void processTextMessage(
const QString& message,
const WSClient& w);
100 void processBinaryMessage(QByteArray message,
const WSClient& w);
102 void sendMessage(
const QString& str);
104 void socketDisconnected();
106 const std::vector<WSClient>& clients()
const noexcept {
return m_clients; }
109 void on_valueUpdated(const ::State::Address& addr,
const ossia::value& v);
111 QWebSocketServer m_server;
112 std::vector<WSClient> m_clients;
114 Explorer::DeviceDocumentPlugin& m_dev;
115 std::list<Path<Scenario::TimeSyncModel>> m_activeSyncs;
117 score::hash_map<QString, std::function<void(
const rapidjson::Value&,
const WSClient&)>>
119 score::hash_map<::State::Address, WSClient> m_listenedAddresses;
121 std::vector<std::pair<QObject*, Handler>> m_handlers;
130 void timerEvent(QTimerEvent* event)
override;
135 void on_documentClosing()
override;
146 const double* progress;
150 ossia::hash_map<int64_t, IntervalData> m_intervals;
Definition: plugins/score-plugin-remotecontrol/RemoteControl/DocumentPlugin.hpp:125
Definition: Interval.hpp:44
Definition: IntervalModel.hpp:50
Definition: TreeNode.hpp:52
Extend a document with custom data and systems.
Definition: DocumentPluginBase.hpp:24
Manipulation of Devices from Qt.
Definition: AddressSettings.cpp:14
TreeNode< DeviceExplorerNode > Node
Definition: DeviceNode.hpp:74
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: plugins/score-plugin-remotecontrol/RemoteControl/DocumentPlugin.hpp:45
void setupDefaultHandler(T msgs)
Helper function to set handlers from a pair of init / deinit functions.
Definition: plugins/score-plugin-remotecontrol/RemoteControl/DocumentPlugin.hpp:58
Definition: plugins/score-plugin-remotecontrol/RemoteControl/DocumentPlugin.hpp:85
Definition: plugins/score-plugin-remotecontrol/RemoteControl/DocumentPlugin.hpp:36
Definition: DocumentContext.hpp:18