OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
qml_http_request.hpp
1#pragma once
2#include <ossia/network/context.hpp>
3#include <ossia/network/http/http_client.hpp>
4
5#include <ossia-qt/protocols/utils.hpp>
6#include <ossia-qt/qml_protocols.hpp>
7
8#include <verdigris>
9
10namespace ossia::qt
11{
12
13struct qml_protocols_http_answer;
14struct qml_protocols_http_error;
15using request_type
16 = ossia::net::http_get_request<qml_protocols_http_answer, qml_protocols_http_error>;
17
18struct qml_protocols_http_answer
19{
20 static constexpr int reserve_expect = 65536 * 8;
21 QPointer<qml_protocols> self{};
22 QJSValue v;
23 void operator()(auto& req, std::string_view str)
24 {
25 ossia::qt::run_async(self.get(), [self = self, v = v, s = QString::fromUtf8(str)] {
26 if(self)
27 if(v.isCallable())
28 v.call({s});
29 });
30 }
31};
32struct qml_protocols_http_error
33{
34 void operator()(auto& self) { }
35};
36
37}
Definition qml_device.cpp:43