+// Client is requesting a STAT (name and modification time) of the current room
+void json_stat(struct http_transaction *h, struct ctdlsession *c) {
+ char buf[1024];
+ char field[1024];
+
+ ctdl_printf(c, "STAT");
+ ctdl_readline(c, buf, sizeof(buf));
+ syslog(LOG_DEBUG, "%s", buf);
+ if (buf[0] == '2') {
+ JsonValue *j = NewJsonObject(HKEY("stat"));
+ extract_token(field, &buf[4], 0, '|', sizeof field);
+ JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), field, -1));
+ JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), extract_long(&buf[4], 1)));
+
+ StrBuf *sj = NewStrBuf();
+ SerializeJson(sj, j, 1); // '1' == free the source array
+ add_response_header(h, strdup("Content-type"), strdup("application/json"));
+ h->response_code = 200;
+ h->response_string = strdup("OK");
+ h->response_body_length = StrLength(sj);
+ h->response_body = SmashStrBuf(&sj);
+ }
+ else {
+ do_404(h);
+ }
+ return;
+}
+
+