PubSub system (#346)
* Add websocketpp dependency * Initial pubsub commit Renamed selection min and max variables to selectionMin and selectionMax to bypass windows min/max macros being stupid. TwitchAccount is now initialized with its User ID. It cannot be changed after it has been initialized. * Update openssl folder * Update installation instructions * Split up websocketpp dependency to its own code only and openssl.pri * Add missing include to asio steady_timer * Update dependencies for linux
This commit is contained in:
@@ -133,7 +133,7 @@ public:
|
||||
if (cachedFile.open(QIODevice::ReadOnly)) {
|
||||
QByteArray bytes = cachedFile.readAll();
|
||||
|
||||
qDebug() << "loaded cached resource" << this->data.request.url();
|
||||
// qDebug() << "Loaded cached resource" << this->data.request.url();
|
||||
|
||||
onFinished(bytes);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "util/rapidjson-helpers.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace rj {
|
||||
|
||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
obj.AddMember(rapidjson::Value(key, a).Move(), value, a);
|
||||
}
|
||||
|
||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
obj.AddMember(rapidjson::Value(key, a).Move(), value.Move(), a);
|
||||
}
|
||||
|
||||
} // namespace rj
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/serialize-custom.hpp"
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace chatterino {
|
||||
namespace rj {
|
||||
|
||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &&value,
|
||||
rapidjson::Document::AllocatorType &a);
|
||||
void addMember(rapidjson::Value &obj, const char *key, rapidjson::Value &value,
|
||||
rapidjson::Document::AllocatorType &a);
|
||||
|
||||
template <typename Type>
|
||||
void set(rapidjson::Value &obj, const char *key, const Type &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void set(rapidjson::Value &obj, const char *key, const rapidjson::Value &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void set(rapidjson::Document &obj, const char *key, const Type &value)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto &a = obj.GetAllocator();
|
||||
|
||||
addMember(obj, key, pajlada::Settings::Serialize<Type>::get(value, a), a);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void set(rapidjson::Document &obj, const char *key, const rapidjson::Value &value)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
auto &a = obj.GetAllocator();
|
||||
|
||||
addMember(obj, key, const_cast<rapidjson::Value &>(value), a);
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
void add(rapidjson::Value &arr, const Type &value, rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
assert(arr.IsArray());
|
||||
|
||||
arr.PushBack(pajlada::Settings::Serialize<Type>::get(value, a), a);
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
|
||||
{
|
||||
if (!obj.IsObject()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!obj.HasMember(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
out = pajlada::Settings::Deserialize<Type>::get(obj[key]);
|
||||
} catch (const std::runtime_error &) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
bool getSafe(const rapidjson::Value &value, Type &out)
|
||||
{
|
||||
try {
|
||||
out = pajlada::Settings::Deserialize<Type>::get(value);
|
||||
} catch (const std::runtime_error &) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace rj
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user