$result['data']['timestamp'] = gmdate('Y-m-d H:i:s.', $t) . $micro; // $result['data']['timestamp'] = gmdate("Y-m-d H:i:s"); $room = null; $timestamp = null; if (isset($_REQUEST['room'])) { $room = $_REQUEST['room']; } else { throw new Exception('ERROR NO ROOM SPECIFIED.'); } if (isset($_REQUEST['timestamp'])) { $timestamp = $_REQUEST['timestamp']; } $key = 'chat_room_' . $room; // Retrieve the messages // $message_list = array(); $message_list = data_store_get($key); // Filter out messages that happened before the timestamp. if (isset($timestamp)) { // echo json_encode($message_list); // echo '<br><br>'; // Loop backwards and remove messages that come before the timestamp filter. for ($index_message = count($message_list) - 1; $index_message > -1; --$index_message) { $message = $message_list[$index_message]; // If the timestamp of the message is before the timestamp // filter, remove the message from the list. if (strcmp($message['timestamp'], $GLOBALS['timestamp']) < 0) { array_splice($message_list, $index_message, 1); } } // echo json_encode($message_list); // echo '<br><br>';
$timeout = 0; $key = null; if (isset($_REQUEST['group'])) { $group = $_REQUEST['group']; } else { throw new Exception('ERROR NO GROUP SPECIFIED.'); } if (isset($_REQUEST['timeout'])) { $timeout = (int) $_REQUEST['timeout']; } if (isset($_REQUEST['key'])) { $key = $_REQUEST['key']; } $data_key = 'player_data_' . $group; // Retrieve the data $data = data_store_get($data_key); $player_data = array(); if (isset($key)) { // Retrieve the specific player if it exists. if (isset($data[$key])) { $player_data = $data[$key]; } } else { $player_data = $data; // Filter out those who exceed the timeout. $player_data = filter_player_data_by_timeout($player_data, $timeout); } $result['data']['player_data'] = $player_data; } catch (Exception $e) { $result['error'] = $e->getMessage(); }