This commit is contained in:
2024-07-17 15:55:47 +08:00
parent a5bc417c69
commit 69f1bcbb96

View File

@@ -63,31 +63,42 @@ class TychatLogic extends BaseLogic
//保存记录
$obj->saveHistory($username,$chat_msg);
//广播消息
//查询广播客户端id
$arr = Db::table('fa_ty_users')
->where('username',$username)
->select();
$clientid_arr = array_column($arr,'clientid');
$json = Tools::wss_json($action, $chat_msg);
Gateway::sendToAll($json, $clientid_arr);
//将消息转发到绑定关系的对方
//判断用户类型,医生还是病人
if($user['type']=='doc'){
//消息发给病人
$client_id = Db::table('fa_ty_users')
->where('doctor',$username)
->value('clientid');
if(empty($client_id)){
$json = Tools::wss_json($action, '病人未上线');
return Gateway::sendToClient($client_id, $json);
}
$json = Tools::wss_json($action, '成功',['chat_msg'=>$chat_msg]);
return Gateway::sendToClient($client_id, $json);
}else{
//消息发给医生
$client_id = Db::table('fa_ty_users')
->where('username',$user['doctor'])
->value('clientid');
if(empty($client_id)){
$json = Tools::wss_json($action, '医生未上线');
return Gateway::sendToClient($client_id, $json);
}
$json = Tools::wss_json($action, '成功',['chat_msg'=>$chat_msg]);
return Gateway::sendToClient($client_id, $json);
}
//if($user['type']=='doc'){
// //消息发给病人
// $client_id = Db::table('fa_ty_users')
// ->where('doctor',$username)
// ->value('clientid');
// if(empty($client_id)){
// $json = Tools::wss_json($action, '病人未上线');
// return Gateway::sendToClient($client_id, $json);
// }
// $json = Tools::wss_json($action, '成功',['chat_msg'=>$chat_msg]);
// return Gateway::sendToClient($client_id, $json);
//}else{
// //消息发给医生
// $client_id = Db::table('fa_ty_users')
// ->where('username',$user['doctor'])
// ->value('clientid');
// if(empty($client_id)){
// $json = Tools::wss_json($action, '医生未上线');
// return Gateway::sendToClient($client_id, $json);
// }
// $json = Tools::wss_json($action, '成功',['chat_msg'=>$chat_msg]);
// return Gateway::sendToClient($client_id, $json);
//}
});
}
/**