From 9c20000fb8871437dafb41ec830afbf56a746a57 Mon Sep 17 00:00:00 2001 From: BlueRaja Date: Sun, 9 Jun 2013 01:03:03 -0500 Subject: Attempting to remove the multiple calls to getChat(); however, I seem to have broken chat... --- ajax/chat.ajax.php | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'ajax') diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index 02a11c6..f9370aa 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -111,35 +111,22 @@ if (isset($_REQUEST['messages'])) { if ($_REQUEST['getChatFromID']) { $getChatID = $_REQUEST['getChatFromID']; if ($sent) { - //Wait .2 seconds - usleep(200000); - //echo "yesSent"; - for( $i = 1; $i < 3; $i++) { - //echo "loop"; - $data = getChat($getChatID); - if ($data !== false) { - //$data['debug'][] = "Count times: $i"; - //$data['debug'][] = "Count value:".count($data); - echo prepareChatData($data); - exit; - } - //Wait .1 seconds - usleep(100000); - } + $data = getChat($getChatID); + echo prepareChatData($data); + exit; } - $json = prepareChatData(getChat($getChatID)); - echo $json; } exit; function prepareChatData($data) { - if ($data) { - foreach($data as &$user) { - //$user['message'] = $user['message'].'write-append'; - $user['secondsSince'] = strtotime($user['dateSent']) - strtotime("now"); - } - return json_encode($data); + if (!$data) + { + return false; + } + foreach($data as &$user) { + //$user['message'] = $user['message'].'write-append'; + $user['secondsSince'] = strtotime($user['dateSent']) - strtotime("now"); } - return $data; + return json_encode($data); } ?> \ No newline at end of file -- cgit v1.2.3