本文整理汇总了PHP中Chat::retrieveNewMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::retrieveNewMessages方法的具体用法?PHP Chat::retrieveNewMessages怎么用?PHP Chat::retrieveNewMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::retrieveNewMessages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_encode
if ($mode == 'SendAndRetrieveNew') {
// retrieve the action parameters used to add a new message
$name = $_POST['name'];
$message = $_POST['message'];
$color = $_POST['color'];
$id = $_POST['id'];
// check if we have valid values
if ($name != '' && $message != '' && $color != '') {
// post the message to the database
$chat->postMessage($name, $message, $color);
}
} elseif ($mode == 'DeleteAndRetrieveNew') {
// delete all existing messages
$chat->deleteMessages();
} elseif ($mode == 'RetrieveNew') {
// get the id of the last message retrieved by the client
$id = $_POST['id'];
}
// Clear the output
if (ob_get_length()) {
ob_clean();
}
// Headers are sent to prevent browsers from caching
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: application/json');
// retrieve new messages from the server
echo json_encode($chat->retrieveNewMessages($id));
示例2: Chat
$chat = new Chat();
//Create object of class chat
$id = 0;
//Default value of id
//If request is to send message
if (isset($_POST['json_sendMessage'])) {
$json_decode = json_decode($_POST['json_sendMessage']);
$name = $json_decode->name;
$message = $json_decode->message;
$id = $json_decode->id;
if ($name != '' && $message != '') {
$chat->postMessage($name, $message);
//Call post message function
}
} else {
if (isset($_POST['json_requestNewMessages'])) {
$chat->CreateTable();
//Create table if not exist
$json_decode = json_decode($_POST['json_requestNewMessages']);
$id = $json_decode->id;
}
}
if (ob_get_length()) {
ob_clean();
}
//Clear buffer for previous content
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/xml');
echo $chat->retrieveNewMessages($id);
//Call retrive message function which prints output
示例3: iconv
} else {
$ptype = 0;
$to = 0;
}
$message = iconv("Windows-1251", "UTF-8//IGNORE", $message);
$say = $chat->postMessage($message, $color, $to, $user_id, $channel, $ptype);
$message = iconv("UTF-8", "Windows-1251//IGNORE", $message);
if (strpos("{$message}", "Нафаня, ") === 0) {
$selpech = myquery("select count(*) from game_chat_nakaz where town=0 AND user_id='{$user_id}' and date_zak>'" . time() . "'");
$userpech = 0;
if ($selpech != false and mysql_num_rows($selpech) > 0) {
$userpech = mysql_result($selpech, 0, 0);
}
if ($userpech == 0) {
include 'bot/index.php';
}
}
}
}
}
if (ob_get_length()) {
ob_clean();
}
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/javascript');
$_SESSION['lastMessageID'] = $id;
echo $json->encode($chat->retrieveNewMessages($user_id, $id, $char['clan_id'], $char['sklon']));