aboutsummaryrefslogtreecommitdiff
path: root/xW/xW.cpp
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-05-08 13:04:22 +0200
committerPřemysl Eric Janouch <p@janouch.name>2025-05-08 13:33:59 +0200
commita3dd82d6be22d5874136688f27f58dd9e67971cf (patch)
treeaf94838d7149ed83ec2c4446f59ac15f817dfcca /xW/xW.cpp
parentd572cfeb40b996a898f6d67d273fac2fab37c86e (diff)
downloadxK-a3dd82d6be22d5874136688f27f58dd9e67971cf.tar.gz
xK-a3dd82d6be22d5874136688f27f58dd9e67971cf.tar.xz
xK-a3dd82d6be22d5874136688f27f58dd9e67971cf.zip
WIP: Acknowledge received commandsHEADmaster
Event the smallest protocol change has great consequences. Relay events have been reordered to improve forward compatibility. WIP: - xM handling (send) - xA handling (relaySend) - xC: fix connection killing
Diffstat (limited to 'xW/xW.cpp')
-rw-r--r--xW/xW.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/xW/xW.cpp b/xW/xW.cpp
index 7fd8950..0840c16 100644
--- a/xW/xW.cpp
+++ b/xW/xW.cpp
@@ -222,6 +222,14 @@ relay_try_write(std::wstring &error)
}
static void
+on_relay_generic_response(
+ std::wstring error, const Relay::ResponseData *response)
+{
+ if (!response)
+ show_error_message(error.c_str());
+}
+
+static void
relay_send(Relay::CommandData *data, Callback callback = {})
{
Relay::CommandMessage m = {};
@@ -232,6 +240,8 @@ relay_send(Relay::CommandData *data, Callback callback = {})
if (callback)
g.command_callbacks[m.command_seq] = std::move(callback);
+ else
+ g.command_callbacks[m.command_seq] = on_relay_generic_response;
uint32_t len = htonl(w.data.size());
uint8_t *prefix = reinterpret_cast<uint8_t *>(&len);