diff options
Diffstat (limited to 'ajax')
-rw-r--r-- | ajax/chat.ajax.php | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index f9370aa..8302c33 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -6,6 +6,12 @@ session_start(); // exit;
// }
+
+ini_set('display_errors',1);
+ini_set('display_startup_errors',1);
+error_reporting(-1);
+
+
if (isset($_SESSION['chatLastReset'])) $chatLastReset = $_SESSION['chatLastReset'];
else $chatLastReset = 0;
@@ -31,6 +37,8 @@ session_write_close(); $userID = $_SESSION['userID'];
$chatLockDown = false;
+$use_psuedo_longpoll = true;
+
// STOP CHAT?
//$chatLockDown = true;
@@ -42,6 +50,7 @@ $chatLockDown = false; require_once('../includes/chats.php');
+
$sent = false;
if (isset($_REQUEST['messages'])) {
@@ -110,13 +119,23 @@ if (isset($_REQUEST['messages'])) { if ($_REQUEST['getChatFromID']) {
$getChatID = $_REQUEST['getChatFromID'];
- if ($sent) {
- $data = getChat($getChatID);
- echo prepareChatData($data);
- exit;
+ if ($sent == true AND $use_psuedo_longpoll == true) {
+ // PSUEDO LONG POLLING: - This loops to try to retrieve
+ // the message you just sent, back from the server.
+
+ for( $i = 1; $i < 3; $i++) {
+ $data = getChat($getChatID);
+ if ($data !== false) {
+ echo prepareChatData($data);
+ exit;
+ }
+ //Wait .01 seconds per loop
+ usleep(10000);
+ }
}
+ $json = prepareChatData(getChat($getChatID));
+ echo $json;
}
-exit;
function prepareChatData($data) {
if (!$data)
|