更新
This commit is contained in:
@@ -11,7 +11,7 @@ use fast\Tencentst;
|
||||
|
||||
class Tencent extends Model
|
||||
{
|
||||
|
||||
|
||||
//获取腾讯IM UserSig信息
|
||||
//$uid => 用户id
|
||||
public function tencent_user_sig_info($uid){
|
||||
@@ -39,7 +39,7 @@ class Tencent extends Model
|
||||
'UserID' => 'u'.$uid,
|
||||
'Nick' => '',
|
||||
'FaceUrl' => '',
|
||||
);
|
||||
);
|
||||
if($data){
|
||||
//添加用户信息 昵称和头像
|
||||
$curlPost['Nick'] = $data['nick'];
|
||||
@@ -99,7 +99,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//查询账号
|
||||
//$uid => 用户id
|
||||
public function account_check($uid){
|
||||
@@ -108,19 +108,19 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/im_open_login_svc/account_check?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'CheckItem' => array(
|
||||
array(
|
||||
'UserID' => 'u'.$uid, //
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// var_dump($reslut);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -134,7 +134,7 @@ class Tencent extends Model
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//拉入黑名单
|
||||
public function black_list_add($uid, $receive_uid){
|
||||
$config = get_system_config();
|
||||
@@ -142,25 +142,25 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/sns/black_list_add?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'From_Account' => $uid,
|
||||
'To_Account' => [$receive_uid],
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
// Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 200, 'msg' => '添加成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 201, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//移除黑名单
|
||||
public function black_list_delete($uid, $receive_uid){
|
||||
$config = get_system_config();
|
||||
@@ -168,16 +168,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/sns/black_list_delete?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'From_Account' => $uid,
|
||||
'To_Account' => [$receive_uid],
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 200, 'msg' => '移除成功', 'data' => null];
|
||||
@@ -185,7 +185,7 @@ class Tencent extends Model
|
||||
return ['code' => 201, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送群内系统消息
|
||||
public function send_group_system_notification($rid, $message_data){
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($rid.$message_data),"info");
|
||||
@@ -196,16 +196,16 @@ class Tencent extends Model
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/send_group_system_notification?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'GroupId' => $rid,
|
||||
'Content' => $message_data,
|
||||
);
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($reslut),"info");
|
||||
// Log::record("腾讯群内系统消息发送结果".json_encode($reslut),"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => $reslut];
|
||||
}else{
|
||||
@@ -241,28 +241,28 @@ class Tencent extends Model
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("广播消息信息".json_encode($reslut),"info");
|
||||
Log::record("广播消息信息3".json_encode($admin_sig),"info");
|
||||
Log::record("广播消息信息2".$admin_sig,"info");
|
||||
// Log::record("广播消息信息".json_encode($reslut),"info");
|
||||
// Log::record("广播消息信息3".json_encode($admin_sig),"info");
|
||||
// Log::record("广播消息信息2".$admin_sig,"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '发送成功', 'data' => $reslut];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送群内普通消息
|
||||
public function send_group_msg($rid, $message_data, $uid=''){
|
||||
|
||||
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$random = time().rand(111,999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'GroupId' => $rid,
|
||||
'From_Account' => $uid,
|
||||
@@ -272,18 +272,18 @@ class Tencent extends Model
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message_data,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// $txt = date('Y-m-d H:i:s').'测试';
|
||||
// error_log($txt, 3, 'a.txt');
|
||||
return $reslut;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -305,8 +305,8 @@ class Tencent extends Model
|
||||
'GroupId' => strval($rid),
|
||||
'Name' => $group_name,
|
||||
'FaceUrl' => $url
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
@@ -337,7 +337,7 @@ class Tencent extends Model
|
||||
'Member_Account' => 'u'.$uid,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -359,12 +359,12 @@ class Tencent extends Model
|
||||
$curlPost = array(
|
||||
'GroupId' => strval($rid),
|
||||
'MemberToDel_Account' => array(
|
||||
'u'.$uid
|
||||
'u'.$uid
|
||||
),
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯群内删除成员结果".json_encode($reslut),"info");
|
||||
// Log::record("腾讯群内删除成员结果".json_encode($reslut),"info");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
@@ -382,7 +382,7 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/destroy_group?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost = array(
|
||||
'GroupId' => strval($rid),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -391,7 +391,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//指定用户发送消息给用户
|
||||
public function user_sendmsg($uid, $receive_uid, $message, $machine_type = 2, $OnlineOnlyFlag = 0){
|
||||
$config = get_system_config();
|
||||
@@ -399,7 +399,7 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
$curlPost = array(
|
||||
@@ -412,18 +412,18 @@ class Tencent extends Model
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
if($OnlineOnlyFlag == 1){
|
||||
$curlPost['OnlineOnlyFlag'] = 1;
|
||||
}
|
||||
Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
// Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("xitong消息信息2:".$reslut,"info");
|
||||
// Log::record("xitong消息信息2:".$reslut,"info");
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ class Tencent extends Model
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//获取APP中的所有群组
|
||||
public function get_appid_group_list(){
|
||||
$config = get_system_config();
|
||||
@@ -464,40 +464,40 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_appid_group_list?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'Limit' => 20,
|
||||
'Next' => 0,
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function txt(){
|
||||
$postUrl = 'https://app.yayinyy.com/api/Agora/get_sstoken';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'code' => '44863d01cd628e583efeb3b9eda510fd',
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//腾讯IM请求封装方法
|
||||
public function tencent_post_url($postUrl, $curlPost){
|
||||
|
||||
|
||||
$headerArray =array(
|
||||
"Content-type:application/json",
|
||||
"Accept:application/json",
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$ch = curl_init();//初始化curl
|
||||
curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
|
||||
// curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
|
||||
@@ -514,7 +514,7 @@ class Tencent extends Model
|
||||
// dump($data);exit;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
//指定用户发送自定义消息给注册用户
|
||||
public function user_custom_sendmsg($uid, $receive_uid, $message, $machine_type = 2){
|
||||
$config = get_system_config();
|
||||
@@ -522,9 +522,9 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'SyncOtherMachine' => $machine_type,
|
||||
'From_Account' => strval($uid),
|
||||
@@ -537,16 +537,16 @@ class Tencent extends Model
|
||||
// 'Text' => $message,
|
||||
'Data' => $message,
|
||||
// 'Desc' => 'notification',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//获取用户在线状态
|
||||
public function query_user_online_status($to_uid_arr)
|
||||
{
|
||||
@@ -558,16 +558,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/query_online_status?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'To_Account' => $to_uid_arr,
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
@@ -581,13 +581,13 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_online_member_num?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost = array(
|
||||
'GroupId' => 'room'.$group_id,
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//主动审核接口
|
||||
public function content_moderation($type_name, $content){
|
||||
return ['code' => 1, 'msg' => '通过审核', 'data' => null];
|
||||
@@ -597,17 +597,17 @@ class Tencent extends Model
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$random = time().rand(111,999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/im_msg_audit/content_moderation?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'AuditName' => 'C2C', //表明送审策略,取值:C2C/Group/UserInfo/GroupInfo/GroupMemberInfo/RelationChain
|
||||
'ContentType' => $type_name, //送审类型,取值:Text/Image/Audio/Video。
|
||||
'Content' => $content //送审内容,最大限制8KB,当审核文件时,填对应 URL。其中图片审核最大不超过5MB
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
if($reslut['Result'] == 'Pass'){
|
||||
@@ -655,14 +655,14 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $group_id;
|
||||
if($group_name){
|
||||
$curlPost['Name'] = $group_name;
|
||||
}
|
||||
if($group_face_url){
|
||||
$curlPost['FaceUrl'] = $group_face_url;
|
||||
}
|
||||
if($group_notice){
|
||||
$curlPost['Notification'] = $group_notice;
|
||||
}
|
||||
$curlPost['Name'] = $group_name;
|
||||
}
|
||||
if($group_face_url){
|
||||
$curlPost['FaceUrl'] = $group_face_url;
|
||||
}
|
||||
if($group_notice){
|
||||
$curlPost['Notification'] = $group_notice;
|
||||
}
|
||||
// $curlPost = array(
|
||||
// 'GroupId' => $group_id,
|
||||
// 'Name' => $group_name,//群名称
|
||||
@@ -692,7 +692,7 @@ class Tencent extends Model
|
||||
$curlPost['GroupId'] = $group_id;
|
||||
$curlPost['Member_Account'] = $member_id;//群成员帐号
|
||||
if($member_role == 1){
|
||||
$curlPost['Role'] = 'Admin';//群成员角色,取值:Owner(群主),Admin(群管理员),Member(普通群成员)
|
||||
$curlPost['Role'] = 'Admin';//群成员角色,取值:Owner(群主),Admin(群管理员),Member(普通群成员)
|
||||
}elseif ($member_role == 2){
|
||||
$curlPost['Role'] = 'Member';
|
||||
}
|
||||
@@ -754,7 +754,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//====新写的↓=====上面的 能用则用=============================================================================================================
|
||||
|
||||
// 获取 Access Token(需缓存并定时刷新,每20分钟一次)
|
||||
@@ -838,7 +838,13 @@ class Tencent extends Model
|
||||
|
||||
// 处理响应
|
||||
if ($httpCode == 200) {
|
||||
return json_decode($response, true)['result']['faceId'];
|
||||
$red = json_decode($response, true);
|
||||
if ($red['code'] == 0) {
|
||||
return $red['result']['faceId'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => $red['msg'], 'data' => null];
|
||||
}
|
||||
// return json_decode($response, true)['result']['faceId'];
|
||||
} else {
|
||||
return ['code' => $httpCode, 'msg' => '接口请求失败'];
|
||||
}
|
||||
@@ -909,24 +915,163 @@ class Tencent extends Model
|
||||
}
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_change($info){
|
||||
public function tencent_member_status_changeee($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
|
||||
Log::record("腾讯离线推送,房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id']);
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
$bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
if(!$bg_room){
|
||||
Log::record("腾讯离线推送,要踢你","infos");
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ($action == 'Login') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
$room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
|
||||
$text['text'] = '重新上线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 1;
|
||||
model('Chat')->sendMsg(1058,$room,$text);
|
||||
}elseif ($action == 'Logout'){
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// $room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
// $text['text'] = '掉线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// model('Chat')->sendMsg(1058,$room,$text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_change($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
$is_keep = 1;
|
||||
$keep = db::name('vs_xintiao')->where('user_id' , $uid)->find();
|
||||
if(isset($keep)){
|
||||
if(time() - $keep['updatetime'] >= 60){
|
||||
$is_keep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//判断保活用户是否安卓用户
|
||||
$user_system = db::name('user')->where('id' , $uid)->value('system');
|
||||
if($user_system == 'android'){
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
Log::record("腾讯离线推送,用户安卓所在房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
// $bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
// if(!$bg_room){
|
||||
// // Log::record("腾讯离线推送,要踢你","infos");
|
||||
// model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
// }
|
||||
Log::record("腾讯离线推送,判断心跳".$is_keep,"infos");
|
||||
if($is_keep == 0){
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
// Log::record("腾讯离线推送,房间信息".json_encode($quit_room),"infos");
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
if(isset($v['room_id'])){
|
||||
$room_type = db::name('vs_room')->where(['id' => $v['room_id']])->field('step,type_id,label_id')->find();
|
||||
// Log::record("腾讯离线推送,房间类型".json_encode($room_type),"infos");
|
||||
if($room_type['label_id'] == 1 && ($room_type['type_id'] == 1 || $room_type['type_id'] == 8)){
|
||||
// Log::record("腾讯离线推送,我是二卡八","infos");
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}else{
|
||||
if(isset($room_type) && ($room_type['type_id'] == 7 && ($room_type['step'] == 2 ||$room_type['step'] == 3)) || $room_type == 2){
|
||||
$text['text'] = '掉线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 2;
|
||||
model('Chat')->sendMsg(1058,$v['room_id'],$text);
|
||||
}else {
|
||||
//查询是否有切后台的操作
|
||||
$bg_room = db::name('vs_user_in_room_bg')->where(['room_id' => $v['room_id'],'user_id' => $v['user_id']])->find();
|
||||
if(!$bg_room){
|
||||
// Log::record("腾讯离线推送,要踢你","infos");
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$room_type = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} elseif ($action == 'Login') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
$room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
|
||||
$text['text'] = '重新上线!';
|
||||
$text['user_id'] = $uid;
|
||||
$text['type'] = 1;
|
||||
model('Chat')->sendMsg(1058,$room,$text);
|
||||
}elseif ($action == 'Logout'){
|
||||
// Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
// $room = Db::name('vs_room_visitor')->where('user_id', $uid)->order('id desc')->value('room_id');
|
||||
// $text['text'] = '掉线!';
|
||||
// $text['user_id'] = $uid;
|
||||
// $text['type'] = 2;
|
||||
// model('Chat')->sendMsg(1058,$room,$text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user