本文整理汇总了PHP中sendChat函数的典型用法代码示例。如果您正苦于以下问题:PHP sendChat函数的具体用法?PHP sendChat怎么用?PHP sendChat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendChat函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
define('DBPATH', 'localhost');
define('DBUSER', 'root');
define('DBPASS', 'root');
define('DBNAME', 'bdpinos');
// session_start();
global $dbh;
$dbh = mysql_connect(DBPATH, DBUSER, DBPASS);
mysql_selectdb(DBNAME, $dbh);
if ($_GET['action'] == "chatheartbeat") {
chatHeartbeat();
}
if ($_GET['action'] == "sendchat") {
sendChat();
}
if ($_GET['action'] == "closechat") {
closeChat();
}
if ($_GET['action'] == "startchatsession") {
startChatSession();
}
if (!isset($_SESSION['chatHistory'])) {
$_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
$_SESSION['openChatBoxes'] = array();
}
}
示例2: chatHandler
/**
* 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;
}
示例3: define
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
define('DBPATH', 'localhost');
define('DBUSER', 'root');
define('DBPASS', 'vertrigo');
define('DBNAME', 'chat');
session_start();
global $dbh;
$dbh = mysql_connect(DBPATH, DBUSER, DBPASS);
mysql_selectdb(DBNAME, $dbh);
if ($_GET['action'] == "chatheartbeat") {
chatHeartbeat();
}
if ($_GET['action'] == "sendchat") {
sendChat();
}
if ($_GET['action'] == "closechat") {
closeChat();
}
if ($_GET['action'] == "startchatsession") {
startChatSession();
}
if (!isset($_SESSION['chatHistory'])) {
$_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
$_SESSION['openChatBoxes'] = array();
}
function chatHeartbeat()
{
示例4: session_start
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
session_start();
global $dbh;
if ($_GET['action'] == "chatheartbeat") { chatHeartbeat(); }
if ($_GET['action'] == "sendchat") { sendChat(); }
if ($_GET['action'] == "closechat") { closeChat(); }
if ($_GET['action'] == "startchatsession") { startChatSession(); }
if (!isset($_SESSION['chatHistory'])) {
$_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
$_SESSION['openChatBoxes'] = array();
}
function chatHeartbeat() {
include("../static/site_config.php");
include ("../static/clase_mysql.php");
$miconexion = new clase_mysql;
示例5: time
// this allows us to track which records have been loaded if multiple tabs for the same chat room are open.
$pageId = Filter::text($_GET['pageId']);
$isValidPageId = Filter::isValidTimestamp($pageId);
if (empty($isValidPageId)) {
$pageId = time();
}
$slug = Filter::text($_GET['slug']);
$project = Project::getProjectFromSlug($slug);
if ($_GET['action'] == "getonlineusers") {
getOnlineUsers($slug);
}
if ($_GET['action'] == "chatheartbeat") {
chatHeartbeat($slug, $pageId);
}
if ($_GET['action'] == "sendchat") {
sendChat($pageId);
}
if ($_GET['action'] == "closechat") {
closeChat();
}
if ($_GET['action'] == "startchatsession") {
startChatSession($pageId);
}
if (!isset($_SESSION['chatHistory'])) {
$_SESSION['chatHistory'] = array();
}
if (!isset($_SESSION['openChatBoxes'])) {
$_SESSION['openChatBoxes'] = array();
}
function chatHeartbeat($slug, $pageId)
{
示例6: wsOnMessage
function wsOnMessage($clientID, $message, $messageLength, $binary)
{
// check if message length is 0
if ($messageLength == 0) {
wsClose($clientID);
return;
}
// split the message by spaces into an array, and fetch the command
$message = explode(' ', $message);
$command = array_shift($message);
// check which command was received
if ($command == 'TEXT') {
// a client has sent chat text to the server
if (!isUser($clientID)) {
// the client has not yet sent a JOIN with a valid username, and is trying to send a TEXT
wsClose($clientID);
return;
}
// put the message back into a string
$text = implode(' ', $message);
if ($text == '') {
// the text is blank
wsSend($clientID, 'SERVER Message was blank.');
return;
}
// fetch the client's username, and send the chat text to all clients
// the text is actually also sent back to the client which sent the text, which sort of acts as a confirmation that the text worked
$username = getUsername($clientID);
sendChat($username, $text);
} elseif ($command == 'JOIN') {
// a client is joining the chat
if (isUser($clientID)) {
// the client has already sent a JOIN with a valid username
wsClose($clientID);
return;
}
// fetch username, and trim any whitespace before and after the username
$username = trim($message[0]);
if ($username == '') {
// the username is blank
wsClose($clientID);
return;
}
if (strlen($username) > CB_MAX_USERNAME_LENGTH) {
// username length is more than CB_MAX_USERNAME_LENGTH
wsSend($clientID, 'SERVER Username length cannot be more than ' . CB_MAX_USERNAME_LENGTH . '.');
wsClose($clientID);
return;
}
if (isUsername($username)) {
// username is already being used by another client
wsSend($clientID, 'SERVER Username already taken.');
wsClose($clientID);
return;
}
// add the user
addUser($clientID, $username);
} elseif ($command == 'QUIT') {
// a client is leaving the chat
if (!isUser($clientID)) {
// the client has not yet sent a JOIN with a valid username, and is trying to send a QUIT
wsClose($clientID);
return;
}
// remove the user
removeUser($clientID);
} else {
// unknown command received, close connection
wsClose($clientID);
}
}
示例7: mysql_real_escape_string
$action = $_POST['action'];
if (isset($_POST['roll'])) {
$to_roll = mysql_real_escape_string($_POST['roll']);
}
if ($action == "startChatSession") {
startChatSession($to_roll, $enroll);
} else {
if ($action == "sendChat") {
$msg = $_POST['msg'];
$to_user = mysql_real_escape_string($_POST['name']);
$t = time() - 3;
$sql = "SELECT NULL FROM stud_data WHERE usr_roll=" . $to_roll . " AND time>=" . $t;
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if ($count == 1) {
sendChat($to_roll, $to_user, $msg, $enroll, $username);
} else {
echo "<root success='no'><user>" . $to_user . "</user></root>";
}
} else {
if ($action == "getChat") {
getChat($to_roll, $enroll);
} else {
if ($action == "setWritingStatus") {
setWritingStatus($enroll, "yes");
} else {
if ($action == "checkMyOnlineStatus") {
checkMyOnlineStatus($enroll);
} else {
if ($action == "setOnlineStatus") {
$status = mysql_real_escape_string($_POST['status']);