wesmiler 2 tahun lalu
induk
melakukan
2ac0d164c0
1 mengubah file dengan 25 tambahan dan 6 penghapusan
  1. 25 6
      app/Console/Commands/SocketServer.php

+ 25 - 6
app/Console/Commands/SocketServer.php

@@ -142,7 +142,7 @@ class SocketServer extends Command
             if ($fromUid && $frameId) {
                 $fds = RedisService::get("chats:bindFds:{$chatKey}");
                 $fds = $fds? $fds : [];
-                $fds[$op.'_'.$fromUid] = $frameId;
+                $fds[$scene.'_'.$fromUid] = $frameId;
                 RedisService::set("chats:bindFds:{$chatKey}", $fds, 86400);
                 RedisService::set("chats:bind:{$scene}_{$fromUid}", ['fd' => $frameId,'scene'=>$scene, 'user_id' => $fromUid, 'uuid' => $uuid, 'chat_key' => $chatKey], 86400);
             }
@@ -274,11 +274,12 @@ class SocketServer extends Command
                     $msgData['nickname'] = MemberModel::where(['id'=> $fromUid])->value('nickname');
                     $msgData['time_text'] = dateFormat($msgData['create_time']);
                     $this->sendMsg($frameId, ['success' => true, 'op' => 'push_live', 'scene'=> $scene, 'data' => $msgData, 'message' => '发送成功:' . $frameId]);
-                    $toBindData = RedisService::get("chats:bind:{$scene}_{$toUid}");
-                    $toFd = isset($toBindData['fd']) ? $toBindData['fd'] : 0;
-                    if ($toBindData && $toFd) {
-                        $this->sendMsg($toFd, ['success' => true, 'op' => 'push_live' ,'scene'=> $scene, 'data' => $msgData, 'message' => '推送消息成功:' . $toFd]);
-                        $this->info("【{$scene} {$date}】Socket:客户端【{$frameId}-{$fromUid}】推送消息给【{$toFd}-{$toUid}。");
+                    $fids =  RedisService::get("chats:bindFds:{$chatKey}");
+                    if($fids){
+                        foreach($fids as $fd){
+                            $this->sendMsg($fd, ['success' => true, 'op' => 'push_live' ,'scene'=> $scene, 'data' => $msgData, 'message' => '推送消息成功:' . $fd]);
+                            $this->info("【{$scene} {$date}】Socket:客户端【{$frameId}-{$fromUid}】推送消息给【{$fd}-{$liveId}。");
+                        }
                     }
 
                     break;
@@ -288,12 +289,30 @@ class SocketServer extends Command
                     break;
                 case 'gift': // 打赏礼物消息
                     $this->sendMsg($frameId, ['success' => true,'op'=> $op, 'scene'=>$scene, 'data' => $data, 'message' => '礼物消息', 't' => time()]);
+                    $fids =  RedisService::get("chats:bindFds:{$chatKey}");
+                    if($fids){
+                        foreach($fids as $fd){
+                            $this->sendMsg($fd, ['success' => true,'op'=> $op, 'scene'=>$scene, 'data' => $data, 'message' => '礼物消息', 't' => time()]);
+                        }
+                    }
                     break;
                 case 'live_entry': // 进入直播间消息
                     $this->sendMsg($frameId, ['success' => true,'op'=> $op, 'scene'=>$scene, 'data' => $data, 'message' => '进入直播间消息', 't' => time()]);
+                    $fids =  RedisService::get("chats:bindFds:{$chatKey}");
+                    if($fids){
+                        foreach($fids as $fd){
+                            $this->sendMsg($fd, ['success' => true,'op'=> $op, 'scene'=>$scene, 'data' => $data, 'message' => '进入直播间消息', 't' => time()]);
+                        }
+                    }
                     break;
                 case 'live_like': // 进入直播间消息
                     $this->sendMsg($frameId, ['success' => true,'op'=> $op, 'scene'=>$scene, 'data' => $data, 'message' => '点赞消息', 't' => time()]);
+                    $fids =  RedisService::get("chats:bindFds:{$chatKey}");
+                    if($fids){
+                        foreach($fids as $fd){
+                            $this->sendMsg($fd, ['success' => true,'op'=> $op, 'scene'=>$scene, 'data' => $data, 'message' => '点赞消息', 't' => time()]);
+                        }
+                    }
                     break;
                 default:
                     $this->sendMsg($frameId, ['success' => false, 'message' => 'ok', 'scene'=>$scene, 'data' => $data, 't' => time()]);