summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-08 17:25:48 -0500
committerJune McEnroe <june@causal.agency>2019-11-08 17:25:48 -0500
commitda2643bc8039de811b4b0e5e1ce367e9236153cd (patch)
tree816909e0adcfcb9542c18d341b3b0275a26371a3 /client.c
parentJust write the example normally (diff)
downloadpounce-da2643bc8039de811b4b0e5e1ce367e9236153cd.tar.gz
pounce-da2643bc8039de811b4b0e5e1ce367e9236153cd.zip
Only change AWAY status for registered clients
Turns out I did eventually fix this, because I may want to implement
"passive clients" for logging or notification stuff, which wouldn't
affect AWAY status either.
Diffstat (limited to '')
-rw-r--r--client.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/client.c b/client.c
index 3e8b15b..32b5b0f 100644
--- a/client.c
+++ b/client.c
@@ -28,6 +28,8 @@
 
 #include "bounce.h"
 
+static size_t count;
+
 enum Need {
 	NeedNick = 1 << 0,
 	NeedUser = 1 << 1,
@@ -54,6 +56,9 @@ struct Client *clientAlloc(struct tls *tls) {
 }
 
 void clientFree(struct Client *client) {
+	if (!client->need) {
+		if (!--count) serverFormat("AWAY :%s\r\n", clientAway);
+	}
 	tls_close(client->tls);
 	tls_free(client->tls);
 	free(client);
@@ -100,7 +105,10 @@ static void passRequired(struct Client *client) {
 
 static void maybeSync(struct Client *client) {
 	if (client->need == NeedPass) passRequired(client);
-	if (!client->need) stateSync(client);
+	if (!client->need) {
+		stateSync(client);
+		if (!count++) serverFormat("AWAY\r\n");
+	}
 }
 
 typedef void Handler(struct Client *client, struct Message *msg);