mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Enqueue eventLog messages.
This commit is contained in:
parent
0a32f99fbd
commit
ca0023eef6
@ -51,7 +51,7 @@ using Message = PiggyWebSocketClient::Message;
|
||||
static const int64_t kLatencyTimeoutMs = 30000;
|
||||
static const int64_t kPingIntervalMs = 10000;
|
||||
static const int kPingMessage = 6000;
|
||||
static const bool kDisableOfflineQueue = true;
|
||||
static const bool kDisableOfflineQueue = false;
|
||||
static std::atomic<int> nextMessageId(0);
|
||||
|
||||
static inline std::string generateSessionId() {
|
||||
@ -143,7 +143,7 @@ void PiggyWebSocketClient::EnqueueMessage(Message message) {
|
||||
}
|
||||
|
||||
void PiggyWebSocketClient::Connect(const std::string& host, unsigned short port, bool useTls) {
|
||||
auto newUri = "ws://" + host + ":" + std::to_string(port);
|
||||
auto newUri = "ws://" + host + ":" + std::to_string(port) + "?deviceId=musikcube&type=native";
|
||||
if (newUri != this->uri ||
|
||||
useTls != this->useTls ||
|
||||
this->state != State::Connected)
|
||||
|
@ -143,4 +143,5 @@ void RawWebSocketClient::Run() {
|
||||
else if (mode == Mode::TLS) {
|
||||
tlsClient->run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,22 @@
|
||||
|
||||
using namespace musik;
|
||||
|
||||
static inline std::shared_ptr<nlohmann::json> createMessage(
|
||||
const std::string& level, const std::string& tag, const std::string message)
|
||||
{
|
||||
const nlohmann::json json = {
|
||||
{ "name", "/eventLog/send" },
|
||||
{ "data", {
|
||||
{ "type", "console" },
|
||||
{ "level", level },
|
||||
{ "timestamp", 0 },
|
||||
{ "tag", tag },
|
||||
{ "data", nlohmann::json::array({message}) }
|
||||
} }
|
||||
};
|
||||
return std::make_shared<nlohmann::json>(json);
|
||||
}
|
||||
|
||||
PiggyDebugBackend::PiggyDebugBackend(Client client): client(client) {
|
||||
}
|
||||
|
||||
@ -45,14 +61,18 @@ PiggyDebugBackend::~PiggyDebugBackend() {
|
||||
}
|
||||
|
||||
void PiggyDebugBackend::verbose(const std::string& tag, const std::string& string) {
|
||||
client->EnqueueMessage(createMessage("verbose", tag, string));
|
||||
}
|
||||
|
||||
void PiggyDebugBackend::info(const std::string& tag, const std::string& string) {
|
||||
client->EnqueueMessage(createMessage("info", tag, string));
|
||||
}
|
||||
|
||||
void PiggyDebugBackend::warning(const std::string& tag, const std::string& string) {
|
||||
client->EnqueueMessage(createMessage("warn", tag, string));
|
||||
}
|
||||
|
||||
void PiggyDebugBackend::error(const std::string& tag, const std::string& string) {
|
||||
client->EnqueueMessage(createMessage("error", tag, string));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user