本文整理汇总了PHP中Chat::addMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::addMessage方法的具体用法?PHP Chat::addMessage怎么用?PHP Chat::addMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chat
的用法示例。
在下文中一共展示了Chat::addMessage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
protected function run()
{
if ($this->check === self::OK) {
$messageParams = array('text' => $this->params['text'], 'room' => $this->room['id'], 'game' => $this->game['id']);
Chat::addMessage($messageParams);
if ($this->game->getIsHNGag()) {
if ($this->actualPlayer['actual_lifes'] == 1) {
// TODO nejaky priznak ze hrac bol upozorneny a potom mu toto uz nezobrazovat len ho removnut z hry
$message = array('text' => 'nesmies hovorit, lebo stratis posledny zivot', 'toUser' => $this->loggedUser['id']);
$this->addMessage($message);
} else {
// TODO info o tom ze hrac stratil zivot kvoli tomu ze keca
$this->actualPlayer['actual_lifes'] = $this->actualPlayer['actual_lifes'] - 1;
$this->actualPlayer->save();
}
}
}
}
示例2: intval
$actualUrl = Utils::getActualUrl();
$room = intval($_GET['id']);
if (!$room) {
Utils::redirect('rooms.php');
}
Room::addUser($loggedUser['id'], $room);
$gameRepository = new GameRepository();
$game = $gameRepository->getOneByRoom($room);
if ($game) {
$GLOBALS['smarty']->assign('game', $game);
}
if ($_POST && trim($_POST['message'])) {
if (strpos($_POST['message'], '.') === 0) {
$commandResult = Command::execute($_POST['message'], $game);
} else {
Chat::addMessage(trim($_POST['message']), $room);
}
Room::updateUserLastActivity($loggedUser['id'], $room);
Utils::redirect($actualUrl);
}
$messages = Chat::getMessages($room, $loggedUser['id']);
$emoticons = Emoticons::getEmoticons();
$GLOBALS['smarty']->assign('loggedUser', $loggedUser);
$GLOBALS['smarty']->assign('room', $room);
$GLOBALS['smarty']->assign('messages', $messages);
$GLOBALS['smarty']->assign('users', Room::getUsers($room));
$GLOBALS['smarty']->assign('emoticonDir', EMOTICONS_DIR);
$GLOBALS['smarty']->assign('emoticons', $emoticons);
$GLOBALS['smarty']->assign('content', $GLOBALS['smarty']->fetch('room.tpl'));
$GLOBALS['smarty']->assign('bodyAdded', 'onload="JavaScript:timedRefresh(10000, ' . $room . ');"');
echo $GLOBALS['smarty']->fetch('content.tpl');
示例3: Chat
<?php
include './classes/chat.php';
$oChat = new Chat();
if ($_POST) {
$sMessage = $_POST['message'];
$oChat->addMessage($_SESSION['user_id'], $sMessage);
}
示例4: beer
protected static function beer()
{
if (GameUtils::checkTurn(self::$game, self::$player)) {
if (self::$player['phase'] == 2 || self::$player['actual_lifes'] == 0) {
$beer = self::$player->getHasPivoOnHand();
if ($beer) {
if (self::$player->addLife()) {
GameUtils::throwCard(self::$game, self::$player, $beer);
} else {
// ma max zivotov
}
} else {
// nema pivo
}
} else {
// najprv musi tahat karty
}
} else {
Chat::addMessage('Nie si na rade.', self::$room, User::SYSTEM, self::$loggedUser['id']);
}
}
示例5: write
protected final function write()
{
if ($this->messages && is_array($this->messages)) {
foreach ($this->messages as $message) {
Chat::addMessage($message);
}
}
}
示例6: sendMessage
/**
* save the message to the database
* @param $to : PartnerId
* @param $message : message content
* @return array : Containing status
*/
public function sendMessage($to, $message)
{
$Object = new Chat();
$result = $Object->addMessage($to, $message);
return $result;
}
示例7: strtolower
// Load config.php
include_once 'includes/config.php';
// Autoload classes
spl_autoload_register(function ($class) {
include_once 'includes/' . strtolower($class) . '.php';
});
// Instigate classes
$db = new Database($mysql_config);
$session = new Session();
$token = new Token($session);
$chat = new Chat($db, $token, $session);
// Post messages
$post_action = isset($_POST['action']) ? $_POST['action'] : '';
if ($post_action === 'chat_post') {
try {
print $chat->addMessage($_POST['name'], $_POST['message'], $_POST['token']);
} catch (Exception $e) {
print '<li><strong>Error:</strong> <span style="color:red;">' . $e->getMessage() . '</span></li>';
}
return;
}
// Build content
$page = isset($_GET['page']) ? $_GET['page'] : '';
if ($page === 'load_chat') {
try {
print $chat->getPosts();
} catch (Exception $e) {
print '<li><strong>Error:</strong> <span style="color:red;">' . $e->getMessage() . '</span></li>';
}
return;
}
示例8: User
require_once '../include/DB.php';
require_once '../include/Chat.php';
require_once '../include/User.php';
$user = new User();
if ($user->isLogin() !== true) {
echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -4, "errorMessage" => "User not login.")));
exit(0);
}
if (@isset($_GET['action'])) {
$action = $_GET['action'];
if ($action === 'send') {
$chat = new Chat();
if (@isset($_POST['to']) && isset($_POST['message'])) {
$to = $_POST['to'];
$message = $_POST['message'];
echo json_encode($chat->addMessage($user->getUsername(), $to, $message, date('Y-m-d H:i:s', time())));
exit(0);
} else {
echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -16, "errorMessage" => "No user for to or no message.")));
}
} else {
if ($action === 'get') {
$chat = new Chat();
if (@isset($_POST['to'])) {
$to = $_POST['to'];
echo json_encode($chat->getMessage($user->getUsername(), $to));
exit(0);
} else {
echo $errorResponse = json_encode(array("status" => false, "message" => array("errorCode" => -8, "errorMessage" => "the user for to is not find.")));
}
}