当前位置: 首页>>代码示例>>PHP>>正文


PHP Chat::postMessage方法代码示例

本文整理汇总了PHP中Chat::postMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Chat::postMessage方法的具体用法?PHP Chat::postMessage怎么用?PHP Chat::postMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chat的用法示例。


在下文中一共展示了Chat::postMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Chat

$mode = $_POST['mode'];
// default the last message id to 0
$id = 0;
// create a new Chat instance
$chat = new Chat();
// if the operation is SendAndRetrieve
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');
开发者ID:stefanlinux,项目名称:SkillsHub,代码行数:31,代码来源:chat-config.php

示例2: Chat

<?php

require_once "chat.class.php";
//Include chat class
$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');
开发者ID:Ashwin-Kapes,项目名称:MultiUserChat,代码行数:31,代码来源:chat.php

示例3: elseif

                $to = -1;
            } elseif ($to_sklon > 0) {
                $ptype = 3;
                $to = $to_sklon;
            } elseif ($to_clan > 0) {
                $ptype = 2;
                $to = $to_clan;
            } elseif ($too > 0) {
                $ptype = 1;
                $to = $too;
            } 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()) {
开发者ID:themiddleearth,项目名称:RPG.SU,代码行数:31,代码来源:chat_ajax.php


注:本文中的Chat::postMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。