From da465168cadb79dc29fa086651cdd4d7e4ab9cbf Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Wed, 1 May 2013 19:25:32 -0400 Subject: Request timeout recognized by receiver --- user_command.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'user_command.h') diff --git a/user_command.h b/user_command.h index 24c2f3e..2e73c90 100644 --- a/user_command.h +++ b/user_command.h @@ -14,10 +14,24 @@ void process_user_command() { // reset the global variable respond_to_chat_request = 0; - if (strcmp(command, "y\n") == 0) { - accept_callback_accept(); + // first check that we haven't expired + time_t now; + time(&now); + + double diff = difftime(now, chat_requested_time); + + if (diff > REQUEST_TIMEOUT) { + + printf("The request has timed out. \n"); + } else { - accept_callback_decline(); + + if (strcmp(command, "y\n") == 0) { + accept_callback_accept(); + } else { + accept_callback_decline(); + } + } return; -- cgit v1.2.3