From a47b138c7455dee981af9b4fac431a16c0eee675 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Thu, 25 Dec 2025 18:04:42 +0800
Subject: [PATCH] 报名导出修改
---
admin/app/gateway/BusinessEvents.php | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/admin/app/gateway/BusinessEvents.php b/admin/app/gateway/BusinessEvents.php
index 67e7241..8a19c73 100644
--- a/admin/app/gateway/BusinessEvents.php
+++ b/admin/app/gateway/BusinessEvents.php
@@ -54,18 +54,12 @@
public static function onMessage($client_id, $message)
{
$data = json_decode($message, 1);
- $to = 'user_' . !empty($data['to_user_id'])?$data['to_user_id']:0;
+ $to = !empty($data['to_user_id']) ? 'user_' . $data['to_user_id'] : 0;
$from_id = 'user_' . $data['user_id'];
- if ($data['type'] !== 'ping' && $data['type'] !== 'close') {//正常发送消息
+ if ($data['type'] == 'bind') {
// 绑定client_id和user_id
Gateway::bindUid($client_id, $from_id);
- //if (Gateway::isUidOnline($to)) {
- $data['time'] = date('Y-m-d H:i:s');
- Gateway::sendToUid($to, json_encode($data));
- //}
- // 保存消息到数据库
- $Chat = new BusinessChatModel;
- $Chat->sendMessage($data['conversation_id'], $data['user_id'], $data['content'],0,$data['app_id']);
+
} else if ($data['type'] == 'ping') {
//心跳
$data['Online'] = $to && Gateway::isUidOnline($to) ? 'off' : 'on';
@@ -77,10 +71,25 @@
// 消息已读处理
$chatModel = new BusinessChatModel();
$chatModel->markAsRead($data['chat_id'], $data['user_id']);
-
+
// 更新参与者最后阅读时间
$participantModel = new BusinessParticipantModel();
$participantModel->updateLastReadTime($data['conversation_id'], $data['user_id']);
+ if ($to && Gateway::isUidOnline($to)) {
+ Gateway::sendToUid($to, json_encode($data));
+ }
+ } else if ($data['type'] !== 'ping' && $data['type'] !== 'close') {//正常发送消息
+ // 绑定client_id和user_id
+ Gateway::bindUid($client_id, $from_id);
+ // 保存消息到数据库
+ $Chat = new BusinessChatModel;
+ $Chat->sendMessage($data['conversation_id'], $data['user_id'], $data['content'], 0, $data['app_id']);
+ // 检查接收方是否在线
+ if ($to && Gateway::isUidOnline($to)) {
+ $data['send_time'] = time();
+ $data['chat_id']=$Chat->chat_id;
+ Gateway::sendToUid($to, json_encode($data));
+ }
}
}
--
Gitblit v1.9.2