i'm implementing CMR Application in CakePHP Framework 2x. In that app, i have a requirement of Online text Chat, Audio Chat, screen sharing and Video Chat. After searching quite a time, i have ended up with a decision of using CometChat 5.0 Platinum Edition. Work Progress:
Actually right now i'm facing issues in using it with my Applicaton. For resolving issues i have searched google, but there is not a single place to tell me:
Right now it is showing chat bar tray correctly but The Error or Alert i have to see all the time is "Please login to use the chat", after analyzing, i came to know that ChometChat should know about logined user information to start but it seems it can only get it through the sessions or somewhere else, that i probably should know. If u think i had any integeration issues, i'm posting some code here, u can see it urself : (integeration.php)
Advanced Settings:
define('SET_SESSION_NAME',''); // Session name
define('DO_NOT_START_SESSION','1'); // Set to 1 if you have already started the session
define('DO_NOT_DESTROY_SESSION','0'); // Set to 1 if you do not want to destroy session on logout
define('SWITCH_ENABLED','1');
define('INCLUDE_JQUERY','1');
define('FORCE_MAGIC_QUOTES','0');
DATABASE Configurations:
define('DB_SERVER', 'localhost' );
define('DB_PORT', "3306" );
define('DB_USERNAME', 'root' );
define('DB_PASSWORD', '' );
define('DB_NAME', 'cakechat' );
define('TABLE_PREFIX', "" );
define('DB_USERTABLE', "users" );
define('DB_USERTABLE_USERID', "id" );
define('DB_USERTABLE_NAME', "username" );
define('DB_AVATARTABLE', " " );
define('DB_AVATARFIELD', " CONCAT(".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID." ,CONCAT('/',".TABLE_PREFIX.DB_USERTABLE.".user_photo))" );
define('DB_USERTABLE_LASTACTIVITY', "user_lastactive");
Functions 1:
function getUserID() {
$userid = 0;
if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
$_REQUEST['basedata'] = $_SESSION['basedata'];
}
if (!empty($_REQUEST['basedata'])) {
$userid = $_REQUEST['basedata'];
}
if (!empty($_COOKIE['se_auth_token'])) {
$sql = ("select session_auth_user_id from ".TABLE_PREFIX."session_auth where session_auth_key = '".mysql_real_escape_string($_COOKIE['se_auth_token'])."'");
$query = mysql_query($sql);
$session = mysql_fetch_array($query);
$userid = $session['session_auth_user_id'];
}
return $userid;
}
My only request: Please share any reference link or walk-through to make things right and functional, any little effort, will be highly appreciated. Thanks in advance !
user_photoMake sure you have Red5 installed on your localhost to use video,audio and screen sharing functionality, and you are using your localhost as VPS.
Use this configuration in your integration.php (E:\xampp\htdocs\project\app\webroot\cometchat)file :
define('DB_SERVER', $config->default['host']);
define('DB_PORT', '3306');
define('DB_USERNAME', $config->default['login']);
define('DB_PASSWORD', $config->default['password']);
define('DB_NAME', $config->default['database']);
define('TABLE_PREFIX', $config->default['prefix']);
define('DB_USERTABLE', "users");
define('DB_USERTABLE_USERID', "id" );
define('DB_USERTABLE_NAME', "username");
define('DB_AVATARTABLE', " ");
define('DB_AVATARFIELD', " ".TABLE_PREFIX.DB_USERTABLE.".user_photo ");
and make some changes in function getAvatar()
function getAvatar($image) {
if ($image) {
return '../'.$image;
} else {
return '../img/no-image.jpg';
}
}
Add this to your getUserID() function:
/*
if (!empty($_SESSION['Auth']['User']['id'])) {
$userid = $_SESSION['Auth']['User']['id'];
}
*/
function getUserID() {
$userid = 0;
if (!empty($_SESSION['basedata']) && $_SESSION['basedata'] != 'null') {
$_REQUEST['basedata'] = $_SESSION['basedata'];
}
if (!empty($_REQUEST['basedata'])) {
$userid = $_REQUEST['basedata'];
}
if (!empty($_COOKIE['se_auth_token'])) {
$sql = ("select session_auth_user_id from ".TABLE_PREFIX."session_auth where session_auth_key = '".mysql_real_escape_string($_COOKIE['se_auth_token'])."'");
$query = mysql_query($sql);
$session = mysql_fetch_array($query);
$userid = $session['session_auth_user_id'];
}
if (!empty($_SESSION['Auth']['User']['id'])) {
$userid = $_SESSION['Auth']['User']['id'];/*pass logged in user id here, which is stored in your session variable*/
}
return $userid;
}