本文整理汇总了PHP中Chat::updateUserInRoom方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::updateUserInRoom方法的具体用法?PHP Chat::updateUserInRoom怎么用?PHP Chat::updateUserInRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::updateUserInRoom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
$type = $this->tokens[2];
$room_name = $this->tokens[3];
$last_message_id = (int) $this->tokens[4];
$name = $_POST['name'];
$status = (int) $_POST['status'];
$room = Chat::getRoomByName($room_name);
if (!$room) {
$this->error = 'Invalid room name';
return;
}
Chat::putMessages($room['room_id'], $name, $_POST['messages']);
Chat::updateUserInRoom($room['room_id'], $name, $status);
$messages = Chat::getMessagesSinceId($room['room_id'], $last_message_id);
$users = Chat::getUsersByRoomId($room['room_id']);
$this->json->commands = Chat::getCommands();
$this->json->last_message_id = Chat::$last_message_id;
$this->json->messages = $messages;
$this->json->users = $users;
示例2: json_encode
<?php
$type = $this->tokens[2];
$room_name = $this->tokens[3];
$last_message_id = $this->tokens[4];
$name = $_POST['name'];
$room = Chat::getRoomByName($room_name);
if (!$room) {
$this->error = 'Invalid room name';
return;
}
Chat::putMessages($room['room_id'], $name, $_POST['messages']);
Chat::updateUserInRoom($room['room_id'], $name);
$messages = Chat::getMessagesSinceId($room['room_id'], $last_message_id);
$users = Chat::getUsersByRoomId($room['room_id']);
$this->json->commands = Chat::getCommands();
$this->json->last_message_id = Chat::$last_message_id;
$this->json->messages = $messages;
$this->json->users = $users;
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/javascript');
header('HTTP/1.0 200 OK');
echo json_encode($this->json);
exit;