Add ping pong to magichat server

This commit is contained in:
Andrew Pamment 2017-10-02 14:22:37 +10:00
parent d268857953
commit 6f4769855e

View File

@ -248,6 +248,11 @@ int main(int argc, char **argv) {
}
}
}
} else if (strcmp(msg.msg, "PING") == 0) {
snprintf(buffer, 1024, "{\"bbs\": \"SYSTEM\", \"nick\": \"SYSTEM\", \"msg\": \"PONG\" }\n");
if (send(i, buffer, strlen(buffer), 0) == -1) {
perror("send");
}
} else {
for (j=0;j<client_count;j++) {
if (clients[j]->fd == i) {