From 69f1bcbb9618d208dd16fb3df56d2cb3a297549f Mon Sep 17 00:00:00 2001 From: wh <382379437@qq.com> Date: Wed, 17 Jul 2024 15:55:47 +0800 Subject: [PATCH] fixed --- .../application/api/logic/TychatLogic.php | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/digital_doctor/application/api/logic/TychatLogic.php b/digital_doctor/application/api/logic/TychatLogic.php index 9e02666..d6a2c39 100644 --- a/digital_doctor/application/api/logic/TychatLogic.php +++ b/digital_doctor/application/api/logic/TychatLogic.php @@ -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); + //} }); } /**