From e5c8f528fcf30b97daef34ff923d4a566e13a411 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 26 Aug 2015 11:38:05 +1000 Subject: [PATCH] Ping pong --- qcsrc/common/mutators/mutator/social.qc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/mutators/mutator/social.qc b/qcsrc/common/mutators/mutator/social.qc index 7ee332d26..905dfcf9b 100644 --- a/qcsrc/common/mutators/mutator/social.qc +++ b/qcsrc/common/mutators/mutator/social.qc @@ -1,6 +1,8 @@ #ifdef MENUQC REGISTER_MUTATOR(social, true); +void Social_send(int to, string msg); + void Social_parse(entity fh, entity pass, int status) { switch (status) { @@ -16,19 +18,30 @@ void Social_parse(entity fh, entity pass, int status) if (first == "") return; int id = stoi(first); printf("from player %d:\n", id); - for (string input; (input = url_fgets(fh)); ) { - print(input, "\n"); - } + string cmd = url_fgets(fh); + switch (cmd) { + case "ping": + Social_send(id, "pong"); + case "pong": + printf("Player %d is online\n", id); + break; + case "msg": + for (string input; (input = url_fgets(fh)); ) { + print(input, "\n"); + } + break; + default: + printf("Social_parse(): '%s'\n", cmd); + break; + } url_fclose(fh); break; } case URL_READY_CLOSED: break; case URL_READY_ERROR: default: - { printf("Social_parse(): %s\n", ftos(status)); break; - } } } -- 2.39.2