aboutsummaryrefslogtreecommitdiff
path: root/chat_request.h
diff options
context:
space:
mode:
authorBen Burwell <bburwell1@gmail.com>2013-04-30 10:52:41 -0400
committerBen Burwell <bburwell1@gmail.com>2013-04-30 10:52:41 -0400
commit0322fefa7f5f465909ccd95c85a088d9cf83812e (patch)
tree862ac466912289d8adb4bcf58331ce7861848400 /chat_request.h
parentca9e46c937e75df43d2f80f0d957fabb07892c29 (diff)
Changes
Diffstat (limited to 'chat_request.h')
-rw-r--r--chat_request.h46
1 files changed, 4 insertions, 42 deletions
diff --git a/chat_request.h b/chat_request.h
index 8b29886..337b822 100644
--- a/chat_request.h
+++ b/chat_request.h
@@ -21,8 +21,8 @@ void send_chat_request(char * username) {
pthread_mutex_unlock(&peer_table_lock);
struct sockaddr_in server_addr;
- char out_buf[4096];
- char in_buf[4096];
+ char out_buf[GLOBAL_MSG_LENGTH];
+ char in_buf[GLOBAL_MSG_LENGTH];
int retcode;
// create the socket
@@ -57,50 +57,12 @@ void send_chat_request(char * username) {
// set my in_chat flag
strcpy(in_chat, "Y");
- // keep looping until no more input
- int keep_going = 1;
-
- while (keep_going) {
-
- char inp[256];
- printf("chat> ");
- fgets(inp, 140, stdin);
-
- if (strcmp(inp, "/q\n") == 0) {
-
- // send quit message to peer
- strcpy(out_buf, "SESQ");
- send(client_s, out_buf, sizeof(out_buf), 0);
- close(client_s);
-
- // exit the loop
- keep_going = 0;
-
- // print message to user
- printf("Session closed. \n");
-
- // set my in_chat flag
- strcpy(in_chat, "N");
-
- } else {
-
- // send the message
- strcpy(out_buf, "SESMSG:");
- strcat(out_buf, inp);
- send(client_s, out_buf, sizeof(out_buf), 0);
-
- // testing...
- printf("%s \n", out_buf);
-
- }
-
- }
+ // set the user prompt
+ strcpy(prompt, "chat>");
} else {
printf("Session declined. \n");
}
- close(client_s);
-
return;
} \ No newline at end of file