From ebfcf94471a78dd48d6a5a63c0d40da3a67c2486 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Wed, 1 May 2013 19:13:57 -0400 Subject: Sends status broadcast after changing chat flag --- chat_acceptor.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'chat_acceptor.h') diff --git a/chat_acceptor.h b/chat_acceptor.h index 7c57c43..cb42d75 100644 --- a/chat_acceptor.h +++ b/chat_acceptor.h @@ -22,7 +22,7 @@ void *receive_chat_messages(void *arg) { char *message; message = strtok(in_buf, separators); if (strcmp(message, "SESMSG") == 0) { - printf("\n > %s", strtok(NULL, separators)); + printf("\n----> %s", strtok(NULL, separators)); printf("%s ", prompt); fflush(stdout); } @@ -36,10 +36,15 @@ void *receive_chat_messages(void *arg) { printf("\n*** Peer closed the session. *** \n"); + // close the socket close(client_s); + + // update chat flag and broadcast strcpy(in_chat, "N"); - strcpy(prompt, ">"); + status_broadcast_once(); + // reset the prompt + strcpy(prompt, ">"); printf("%s ", prompt); fflush(stdout); @@ -85,8 +90,15 @@ void accept_callback_accept() { char inp[256]; + // update the prompt strcpy(prompt, "chat>"); + + // update chat flag and broadcast strcpy(in_chat, "Y"); + status_broadcast_once(); + + // print info message + printf("Entering chat mode. Type /q to exit. \n"); pthread_t recv_thread; pthread_create(&recv_thread, NULL, receive_chat_messages, NULL); -- cgit v1.2.3