- if (recv_complete_line) {
- sln_printf("\r%79s\r", "");
- if (!strcmp(buf, "000")) {
- color(BRIGHT_WHITE);
- sln_printf("\rExiting chat mode\n");
- sln_flush();
- set_keepalives(KA_YES);
-
- /* Some users complained about the client and
- * server losing protocol synchronization when
- * exiting chat. This little dialog forces
- * everything to be hunky-dory.
- */
- CtdlIPC_chat_send(ipc, "ECHO __ExitingChat__");
- do {
- CtdlIPC_chat_recv(ipc, buf);
- } while (strcmp(buf, "200 __ExitingChat__"));
- return;
- }
- if (num_parms(buf) >= 2) {
- extract_token(c_user, buf, 0, '|', sizeof c_user);
- extract_token(c_text, buf, 1, '|', sizeof c_text);
- if (num_parms(buf) > 2) {
- extract_token(c_room, buf, 2, '|', sizeof c_room);
- scr_printf("Got room %s\n", c_room);
+ /* poll for incoming chat messages */
+ snprintf(buf, sizeof buf, "RCHT poll|%d", seq);
+ CtdlIPC_chat_send(ipc, buf);
+ CtdlIPC_chat_recv(ipc, response);
+
+ if (response[0] == '1') {
+ seq = extract_int(&response[4], 0);
+ extract_token(c_user, &response[4], 2, '|', sizeof c_user);
+ while (CtdlIPC_chat_recv(ipc, c_text), strcmp(c_text, "000")) {
+ sln_printf("\r%79s\r", "");
+ if (!strcmp(c_user, fullname)) {
+ color(BRIGHT_YELLOW);
+ } else if (!strcmp(c_user, ":")) {
+ color(BRIGHT_RED);
+ } else {
+ color(BRIGHT_GREEN);