예제 #1
0
/**
 * chat handler, keys: show, send | params: message
 * @param string $key
 * @param mixed $params
 * @return mixed
 *
 */
function chatHandler($key, $params)
{
    $var = null;
    switch ($key) {
        case 'show':
            $var = getChatHistory($_SESSION['chat']);
            break;
        case 'send':
            //$username = getUsername();
            $var = sendChat($_SESSION['user'], $params);
            break;
        default:
            break;
    }
    return $var;
}
예제 #2
0
function showChat()
{
    $users = getJsonFromFile('users.json');
    if (isset($users->{$_SESSION}['user']->chat)) {
        $_SESSION['status'] = 2;
        $_SESSION['chat'] = $users->{$_SESSION}['user']->chat;
        return getChatHistory($_SESSION['chat']);
    }
    return false;
}
예제 #3
0
    $signature_ts = time();
    $str = sprintf('%s:%s:%s:%s:%s', APPID, $peerid, $convid, $nonce, $signature_ts);
    $signature = sha1sign($str);
    $param = array('convid' => $convid, 'peerid' => $peerid, 'nonce' => $nonce, 'signature_ts' => $signature_ts, 'signature' => $signature, 'limit' => 10);
    $url = 'https://leancloud.cn/1.1/rtm/messages/logs?' . http_build_query($param);
    // $url = 'https://leancloud.cn/1.1/rtm/messages/logs?convid=552119bbe4b043f1c84c0b7a';
    $chatHistory = sendRequest($url, 'GET', $param);
    header("Content-Type: application/json; charset=utf-8");
    return json_decode($chatHistory, 1);
}
$a = queryConv();
if (empty($a["results"])) {
    die("no conversation found");
}
foreach ($a["results"] as $v) {
    if (!empty($v["objectId"])) {
        echo $v["objectId"];
    }
}
header("Content-Type: application/json; charset=utf-8");
//echo json_encode($a);
//sendMessage ();
header("Content-Type: application/json; charset=utf-8");
// createUpdateInfo();
//$his = getChatHistory ();
$from = $_GET['from'];
$to = $_GET['to'];
$his = getChatHistory($from, $to);
echo json_encode($his);
//pushMessageToUserName ( '2dong' );
//userReg();
예제 #4
0
    startChatSession();
}
if ($_GET['action'] == "logoutfromchat") {
    logoutFromChat();
}
if ($_GET['action'] == "logintochat") {
    loginToChat();
}
if ($_GET['action'] == "getchatheartbeat") {
    getChatHeartbeat();
}
if ($_GET['action'] == "getrefreshrate") {
    getRefresh_rate();
}
if ($_GET['action'] == "getchathistory") {
    getChatHistory();
}
function getChatHeartbeat()
{
    $rate = eF_getTableData("module_chat_config", "chatHeartbeatTime", "1");
    foreach ($rate as $r) {
        echo $r['chatHeartbeatTime'];
    }
}
function getRefresh_rate()
{
    $rate = eF_getTableData("module_chat_config", "refresh_rate", "1");
    foreach ($rate as $r) {
        echo $r['refresh_rate'];
    }
}