本文整理汇总了PHP中Chat::insertMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::insertMessage方法的具体用法?PHP Chat::insertMessage怎么用?PHP Chat::insertMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::insertMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
break;
case "update":
$fromUser = $_POST["fromUser"];
// $toUser = $_POST['toUser'];
$wait = $_POST["wait"];
$unreadMsgIds = json_decode($_POST['unreadMessages']);
// $history = $chat->update($fromUser, $toUser, $unreadMsgIds);
$lastMsgId = isset($_POST["lastMsgId"]) ? $_POST["lastMsgId"] : -1;
$history = $chat->update($fromUser, $wait, $unreadMsgIds, $lastMsgId);
echo json_encode($history);
break;
case "insertMessage":
$fromUser = $_POST["fromUser"];
$toUser = $_POST["toUser"];
$msg = $_POST["msg"];
list($msgId, $createDate) = $chat->insertMessage($fromUser, $toUser, $msg);
echo json_encode(array("msg_id" => $msgId, "create_date" => $createDate));
break;
case "getUnreadMessagesCount":
if (isset($_POST["user"])) {
$msgCount = $chat->getIncomingMessagesCount($_POST["user"]);
echo json_encode($msgCount);
}
break;
/*case "getRenderedHistory":
$fromUser = $_POST['fromUser'];
$toUser = $_POST['toUser'];
$pageIndex = $_POST['historyPageIndex'];
$history = $chat->getRenderedHistory($fromUser, $toUser, $pageIndex);
break;*/
/*case "getRenderedHistory":
示例2:
// $users = getUsers();
$users = $chat->getUsers();
echo json_encode($users);
} else {
$fromUser = $_POST['fromUser'];
$toUser = $_POST['toUser'];
if (!(isset($fromUser) and isset($toUser))) {
echo "Params are not setted";
exit;
}
}
switch ($action) {
case "getHistory":
if (isset($_POST['historyPageIndex'])) {
$historyPageIndex = $_POST['historyPageIndex'];
$history = $chat->getHistory($fromUser, $toUser, $historyPageIndex);
} else {
$history = $chat->getHistory($fromUser, $toUser);
}
echo json_encode($history);
break;
case "updateHistory":
$history = $chat->updateHistory($fromUser, $toUser);
echo json_encode($history);
break;
case "insertMessage":
// $jsonMsg = file_get_contents('php://input');
$msg = $_POST['msg'];
$chat->insertMessage($fromUser, $toUser, $msg);
break;
}