From 1af25ef2e6dfd4cc6fc2e4e32e9cbb379fcf0c24 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 27 Feb 2020 03:31:30 -0500 Subject: Add causal.agency/consumer capability --- client.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index 3a1d9d6..74fa38a 100644 --- a/client.c +++ b/client.c @@ -165,9 +165,9 @@ static void handlePass(struct Client *client, struct Message *msg) { static void handleCap(struct Client *client, struct Message *msg) { if (!msg->params[0]) msg->params[0] = ""; - enum Cap avail = CapServerTime | CapPassive | (stateCaps & ~CapSASL); + enum Cap avail = (stateCaps & ~CapSASL) + | CapServerTime | CapConsumer | CapPassive | (clientCA ? CapSASL : 0); const char *values[CapBits] = { [CapSASLBit] = "EXTERNAL" }; - if (clientCA) avail |= CapSASL; if (!strcmp(msg->params[0], "END")) { if (!client->need) return; @@ -553,8 +553,16 @@ void clientConsume(struct Client *client) { struct tm *tm = gmtime(&time.tv_sec); strftime(ts, sizeof(ts), "%FT%T", tm); clientFormat( - client, "@time=%s.%03dZ%c%s\r\n", + client, "@time=%s.%03dZ;causal.agency/id=%zu%c%s\r\n", ts, (int)(time.tv_usec / 1000), + ringPos(client->consumer), + (line[0] == '@' ? ';' : ' '), + (line[0] == '@' ? &line[1] : line) + ); + } else if (client->caps & CapConsumer) { + clientFormat( + client, "@causal.agency/id=%zu%c%s\r\n", + ringPos(client->consumer), (line[0] == '@' ? ';' : ' '), (line[0] == '@' ? &line[1] : line) ); -- cgit 1.4.1