进入房间 子进程发送特效

This commit is contained in:
2025-12-03 11:01:28 +08:00
parent 3a202fb50f
commit e2ee2c8338

View File

@@ -887,28 +887,28 @@ class Room extends Model
$ttex['FromUserInfo'] = db::name('user')->where('id', $user_id)->field('id as user_id,nickname,avatar,sex')->find(); $ttex['FromUserInfo'] = db::name('user')->where('id', $user_id)->field('id as user_id,nickname,avatar,sex')->find();
$ttex['ToUserInfo'] = db::name('user')->where('id', $partner_id)->field('id as user_id,nickname,avatar,sex')->find(); $ttex['ToUserInfo'] = db::name('user')->where('id', $partner_id)->field('id as user_id,nickname,avatar,sex')->find();
$ttex['text'] = 'CP特效'; $ttex['text'] = 'CP特效';
model('api/Chat')->sendMsg(1080, $room_id, $ttex);
// 检查是否支持 pcntl 扩展 // 检查是否支持 pcntl 扩展
if (function_exists('pcntl_fork')) { // if (function_exists('pcntl_fork')) {
$pid = pcntl_fork(); // $pid = pcntl_fork();
//
if ($pid == -1) { // if ($pid == -1) {
// 创建子进程失败,直接推送消息 // // 创建子进程失败,直接推送消息
model('api/Chat')->sendMsg(1080, $room_id, $ttex); // model('api/Chat')->sendMsg(1080, $room_id, $ttex);
} elseif ($pid) { // } elseif ($pid) {
// 父进程,继续执行 // // 父进程,继续执行
// 不等待子进程结束 // // 不等待子进程结束
} else { // } else {
// 子进程,延迟推送消息 // // 子进程,延迟推送消息
sleep(1); // sleep(1);
model('api/Chat')->sendMsg(1080, $room_id, $ttex); // model('api/Chat')->sendMsg(1080, $room_id, $ttex);
sleep(1); // sleep(1);
exit(0); // 子进程结束 // exit(0); // 子进程结束
} // }
} else { // } else {
// 不支持 pcntl直接推送消息 // // 不支持 pcntl直接推送消息
model('api/Chat')->sendMsg(1080, $room_id, $ttex); // model('api/Chat')->sendMsg(1080, $room_id, $ttex);
} // }
} }