aboutsummaryrefslogtreecommitdiff
path: root/xC.lxdr
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 /xC.lxdr
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 'xC.lxdr')
-rw-r--r--xC.lxdr53
1 files changed, 26 insertions, 27 deletions
diff --git a/xC.lxdr b/xC.lxdr
index af0f170..eba914f 100644
--- a/xC.lxdr
+++ b/xC.lxdr
@@ -1,7 +1,8 @@
// Backwards-compatible protocol version.
-const VERSION = 1;
+const VERSION = 2;
// From the frontend to the relay.
+// All commands receive either an Event.RESPONSE, or an Event.ERROR.
struct CommandMessage {
// The command sequence number will be repeated in responses
// in the respective fields.
@@ -32,13 +33,10 @@ struct CommandMessage {
// XXX: Perhaps this should rather be handled through a /buffer command.
case BUFFER_TOGGLE_UNIMPORTANT:
string buffer_name;
- case PING_RESPONSE:
- u32 event_seq;
-
- // Only these commands may produce Event.RESPONSE, as below,
- // but any command may produce an error.
case PING:
void;
+ case PING_RESPONSE:
+ u32 event_seq;
case BUFFER_COMPLETE:
string buffer_name;
string text;
@@ -52,6 +50,9 @@ struct CommandMessage {
struct EventMessage {
u32 event_seq;
union EventData switch (enum Event {
+ ERROR,
+ RESPONSE,
+
PING,
BUFFER_LINE,
BUFFER_UPDATE,
@@ -64,12 +65,28 @@ struct EventMessage {
SERVER_UPDATE,
SERVER_RENAME,
SERVER_REMOVE,
- ERROR,
- RESPONSE,
} event) {
+ // Restriction: command_seq strictly follows the sequence received
+ // by the relay, across both of these replies.
+ case ERROR:
+ u32 command_seq;
+ string error;
+ case RESPONSE:
+ u32 command_seq;
+ union ResponseData switch (Command command) {
+ case BUFFER_COMPLETE:
+ u32 start;
+ string completions<>;
+ case BUFFER_LOG:
+ // UTF-8, but not guaranteed.
+ u8 log<>;
+ default:
+ // Reception acknowledged.
+ void;
+ } data;
+
case PING:
void;
-
case BUFFER_LINE:
string buffer_name;
// Whether the line should also be displayed in the active buffer.
@@ -188,23 +205,5 @@ struct EventMessage {
string new;
case SERVER_REMOVE:
string server_name;
-
- // Restriction: command_seq strictly follows the sequence received
- // by the relay, across both of these replies.
- case ERROR:
- u32 command_seq;
- string error;
- case RESPONSE:
- u32 command_seq;
- union ResponseData switch (Command command) {
- case PING:
- void;
- case BUFFER_COMPLETE:
- u32 start;
- string completions<>;
- case BUFFER_LOG:
- // UTF-8, but not guaranteed.
- u8 log<>;
- } data;
} data;
};